Skip to content

Commit

Permalink
New updates to generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
octokitbot committed Aug 2, 2024
1 parent 990c1de commit 893da72
Show file tree
Hide file tree
Showing 14 changed files with 2,207 additions and 2,118 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,33 @@ See example client instantiations and requests in [example_test.go](pkg/example_
- Test coverage may be viewed in VS Code by running the command `Go: Toggle Test Coverage In Current Package`
- Alternately, you may run `go tool cover -html auth.cov -o auth.html` and open the generated `auth.html` file in a browser to view test coverage

### Initializing

Given that the GHES platform is a self hosted instance when using this SDK you'll need to initialize it with your host and protocol:

```go
client, err := pkg.NewApiClient(
pkg.WithUserAgent("octokit/go-sdk.example-functions"),
pkg.WithRequestTimeout(5*time.Second),
pkg.WithBaseUrl("https://hosted.instance"),
pkg.WithTokenAuthentication(token),
)
```

or by using the `SetBaseUrl` function from the `kiotaHttp.NewNetHttpRequestAdapter`

```go
tokenProvider := auth.NewTokenProvider(
auth.WithUserAgent("octokit/go-sdk.example-functions"),
)
adapter, err := kiotaHttp.NewNetHttpRequestAdapter(tokenProvider)
if err != nil {
log.Fatalf("Error creating request adapter: %v", err)
}
adapter.SetBaseUrl("https://hosted.instance")
client := github.NewApiClient(adapter)
```

### Authentication

This SDK supports [Personal Access Tokens (classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#personal-access-tokens-classic), [fine-grained Personal Access Tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#fine-grained-personal-access-tokens), and [GitHub Apps](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/about-authentication-with-a-github-app) authentication.
Expand Down
18 changes: 10 additions & 8 deletions pkg/authentication/token_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"os"
"strings"
"testing"
"time"

abstractions "github.com/microsoft/kiota-abstractions-go"
http "github.com/microsoft/kiota-http-go"
"github.com/octokit/go-sdk-enterprise-server/pkg"
"github.com/octokit/go-sdk-enterprise-server/pkg/authentication"
"github.com/octokit/go-sdk-enterprise-server/pkg/github"
"github.com/octokit/go-sdk-enterprise-server/pkg/github/user"
"github.com/octokit/go-sdk-enterprise-server/pkg/headers"
)
Expand Down Expand Up @@ -155,19 +155,21 @@ func TestHappyPathIntegration(t *testing.T) {
t.Skip("in order to run integration tests, ensure a valid GITHUB_TOKEN exists in the environment")
}

provider := authentication.NewTokenProvider(
authentication.WithTokenAuthentication(token),
// TODO: Rework this test to fit the platform needs of GHES
client, err := pkg.NewApiClient(
pkg.WithUserAgent("octokit/go-sdk.example-functions"),
pkg.WithRequestTimeout(5*time.Second),
pkg.WithBaseUrl("https://api.github.com"),
pkg.WithTokenAuthentication(token),
)

adapter, err := http.NewNetHttpRequestAdapter(provider)
if err != nil {
log.Fatalf("Error creating request adapter: %v", err)
log.Fatalf("error creating client: %v", err)
}

headers := abstractions.NewRequestHeaders()
_ = headers.TryAdd("Accept", "application/vnd.github.v3+json")

client := github.NewApiClient(adapter)

// Create a new instance of abstractions.RequestConfiguration
requestConfig := &abstractions.RequestConfiguration[user.EmailsRequestBuilderGetQueryParameters]{
Headers: headers,
Expand Down
9 changes: 9 additions & 0 deletions pkg/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ func ExampleApiClient_Octocat_withoutConvenienceConstructor() {
log.Fatalf("Error creating request adapter: %v", err)
}

// TODO: Rework this test to fit the platform needs of GHES
baseUrl := adapter.GetBaseUrl()

// Note: This SDK should be used against a GitHub Enterprise instance, and the below URL is the public GitHub one. It's here only so that tests pass when running `go test ./...`, as the OpenAPI schema for GHES understandably does not include a baseURL.
// When setting up this package for your own usage, call `adapter.SetBaseUrl` or `pkg.WithBaseUrl` with your own GHES base URL.
if baseUrl == "" {
adapter.SetBaseUrl("https://api.github.com")
}

client := github.NewApiClient(adapter)

s := "Salutations"
Expand Down
4,209 changes: 2,128 additions & 2,081 deletions pkg/github/.kiota.log

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pkg/github/events/events_request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type EventsRequestBuilder struct {
i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.BaseRequestBuilder
}
// EventsRequestBuilderGetQueryParameters we delay the public events feed by five minutes, which means the most recent event returned by the public events API actually occurred at least five minutes ago.
// EventsRequestBuilderGetQueryParameters > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
type EventsRequestBuilderGetQueryParameters struct {
// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/[email protected]/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
Page *int32 `uriparametername:"page"`
Expand All @@ -30,7 +30,7 @@ func NewEventsRequestBuilder(rawUrl string, requestAdapter i2ae4187f7daee263371c
urlParams["request-raw-url"] = rawUrl
return NewEventsRequestBuilderInternal(urlParams, requestAdapter)
}
// Get we delay the public events feed by five minutes, which means the most recent event returned by the public events API actually occurred at least five minutes ago.
// Get > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
// returns a []Eventable when successful
// returns a BasicError error when the service returns a 403 status code
// returns a Events503Error error when the service returns a 503 status code
Expand Down Expand Up @@ -58,7 +58,7 @@ func (m *EventsRequestBuilder) Get(ctx context.Context, requestConfiguration *i2
}
return val, nil
}
// ToGetRequestInformation we delay the public events feed by five minutes, which means the most recent event returned by the public events API actually occurred at least five minutes ago.
// ToGetRequestInformation > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
// returns a *RequestInformation when successful
func (m *EventsRequestBuilder) ToGetRequestInformation(ctx context.Context, requestConfiguration *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestConfiguration[EventsRequestBuilderGetQueryParameters])(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) {
requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.GET, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters)
Expand Down
2 changes: 1 addition & 1 deletion pkg/github/kiota-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"descriptionHash": "99C4BF7B517E161AAE656A3B1399347333911F4FB7FEA8C33ED281A98C62E859A0A6C4B2E8106E5F611B15ECA97E5CC2D0EF8853C7C0B2946576DD759708508A",
"descriptionHash": "C01ED5ADEE25E4D6D1D9E651706A597CC824CBF5553F22E945AA5789E3796CAF629D24CB2DD75B7475884E6F54BE672FBEB773CCAF9A0FAB4FCE881861A6C4F5",
"descriptionLocation": "../../../../../schemas/ghes-3.13.json",
"lockFileVersion": "1.0.0",
"kiotaVersion": "1.14.0",
Expand Down
16 changes: 8 additions & 8 deletions pkg/github/models/pull_request_review.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type PullRequestReview struct {
// The html_url property
html_url *string
// Unique identifier of the review
id *int32
id *int64
// The node_id property
node_id *string
// The pull_request_url property
Expand Down Expand Up @@ -153,7 +153,7 @@ func (m *PullRequestReview) GetFieldDeserializers()(map[string]func(i878a80d2330
return nil
}
res["id"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
val, err := n.GetInt32Value()
val, err := n.GetInt64Value()
if err != nil {
return err
}
Expand Down Expand Up @@ -220,8 +220,8 @@ func (m *PullRequestReview) GetHtmlUrl()(*string) {
return m.html_url
}
// GetId gets the id property value. Unique identifier of the review
// returns a *int32 when successful
func (m *PullRequestReview) GetId()(*int32) {
// returns a *int64 when successful
func (m *PullRequestReview) GetId()(*int64) {
return m.id
}
// GetLinks gets the _links property value. The _links property
Expand Down Expand Up @@ -294,7 +294,7 @@ func (m *PullRequestReview) Serialize(writer i878a80d2330e89d26896388a3f487eef27
}
}
{
err := writer.WriteInt32Value("id", m.GetId())
err := writer.WriteInt64Value("id", m.GetId())
if err != nil {
return err
}
Expand Down Expand Up @@ -372,7 +372,7 @@ func (m *PullRequestReview) SetHtmlUrl(value *string)() {
m.html_url = value
}
// SetId sets the id property value. Unique identifier of the review
func (m *PullRequestReview) SetId(value *int32)() {
func (m *PullRequestReview) SetId(value *int64)() {
m.id = value
}
// SetLinks sets the _links property value. The _links property
Expand Down Expand Up @@ -408,7 +408,7 @@ type PullRequestReviewable interface {
GetBodyText()(*string)
GetCommitId()(*string)
GetHtmlUrl()(*string)
GetId()(*int32)
GetId()(*int64)
GetLinks()(PullRequestReview__linksable)
GetNodeId()(*string)
GetPullRequestUrl()(*string)
Expand All @@ -421,7 +421,7 @@ type PullRequestReviewable interface {
SetBodyText(value *string)()
SetCommitId(value *string)()
SetHtmlUrl(value *string)()
SetId(value *int32)()
SetId(value *int64)()
SetLinks(value PullRequestReview__linksable)()
SetNodeId(value *string)()
SetPullRequestUrl(value *string)()
Expand Down
5 changes: 3 additions & 2 deletions pkg/github/networks/item_item_events_request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type ItemItemEventsRequestBuilder struct {
i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.BaseRequestBuilder
}
// ItemItemEventsRequestBuilderGetQueryParameters list public events for a network of repositories
// ItemItemEventsRequestBuilderGetQueryParameters > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
type ItemItemEventsRequestBuilderGetQueryParameters struct {
// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/[email protected]/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
Page *int32 `uriparametername:"page"`
Expand All @@ -30,7 +30,7 @@ func NewItemItemEventsRequestBuilder(rawUrl string, requestAdapter i2ae4187f7dae
urlParams["request-raw-url"] = rawUrl
return NewItemItemEventsRequestBuilderInternal(urlParams, requestAdapter)
}
// Get list public events for a network of repositories
// Get > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
// returns a []Eventable when successful
// returns a BasicError error when the service returns a 403 status code
// returns a BasicError error when the service returns a 404 status code
Expand Down Expand Up @@ -58,6 +58,7 @@ func (m *ItemItemEventsRequestBuilder) Get(ctx context.Context, requestConfigura
}
return val, nil
}
// ToGetRequestInformation > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
// returns a *RequestInformation when successful
func (m *ItemItemEventsRequestBuilder) ToGetRequestInformation(ctx context.Context, requestConfiguration *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestConfiguration[ItemItemEventsRequestBuilderGetQueryParameters])(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) {
requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.GET, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters)
Expand Down
5 changes: 3 additions & 2 deletions pkg/github/orgs/item_events_request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type ItemEventsRequestBuilder struct {
i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.BaseRequestBuilder
}
// ItemEventsRequestBuilderGetQueryParameters list public organization events
// ItemEventsRequestBuilderGetQueryParameters > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
type ItemEventsRequestBuilderGetQueryParameters struct {
// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/[email protected]/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
Page *int32 `uriparametername:"page"`
Expand All @@ -30,7 +30,7 @@ func NewItemEventsRequestBuilder(rawUrl string, requestAdapter i2ae4187f7daee263
urlParams["request-raw-url"] = rawUrl
return NewItemEventsRequestBuilderInternal(urlParams, requestAdapter)
}
// Get list public organization events
// Get > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
// returns a []Eventable when successful
// [API method documentation]
//
Expand All @@ -52,6 +52,7 @@ func (m *ItemEventsRequestBuilder) Get(ctx context.Context, requestConfiguration
}
return val, nil
}
// ToGetRequestInformation > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
// returns a *RequestInformation when successful
func (m *ItemEventsRequestBuilder) ToGetRequestInformation(ctx context.Context, requestConfiguration *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestConfiguration[ItemEventsRequestBuilderGetQueryParameters])(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) {
requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.GET, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type ItemEventsOrgsWithOrgItemRequestBuilder struct {
i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.BaseRequestBuilder
}
// ItemEventsOrgsWithOrgItemRequestBuilderGetQueryParameters this is the user's organization dashboard. You must be authenticated as the user to view this.
// ItemEventsOrgsWithOrgItemRequestBuilderGetQueryParameters this is the user's organization dashboard. You must be authenticated as the user to view this.> [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
type ItemEventsOrgsWithOrgItemRequestBuilderGetQueryParameters struct {
// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/[email protected]/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
Page *int32 `uriparametername:"page"`
Expand All @@ -30,7 +30,7 @@ func NewItemEventsOrgsWithOrgItemRequestBuilder(rawUrl string, requestAdapter i2
urlParams["request-raw-url"] = rawUrl
return NewItemEventsOrgsWithOrgItemRequestBuilderInternal(urlParams, requestAdapter)
}
// Get this is the user's organization dashboard. You must be authenticated as the user to view this.
// Get this is the user's organization dashboard. You must be authenticated as the user to view this.> [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
// returns a []Eventable when successful
// [API method documentation]
//
Expand All @@ -52,7 +52,7 @@ func (m *ItemEventsOrgsWithOrgItemRequestBuilder) Get(ctx context.Context, reque
}
return val, nil
}
// ToGetRequestInformation this is the user's organization dashboard. You must be authenticated as the user to view this.
// ToGetRequestInformation this is the user's organization dashboard. You must be authenticated as the user to view this.> [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
// returns a *RequestInformation when successful
func (m *ItemEventsOrgsWithOrgItemRequestBuilder) ToGetRequestInformation(ctx context.Context, requestConfiguration *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestConfiguration[ItemEventsOrgsWithOrgItemRequestBuilderGetQueryParameters])(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) {
requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.GET, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters)
Expand Down
5 changes: 3 additions & 2 deletions pkg/github/users/item_events_public_request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type ItemEventsPublicRequestBuilder struct {
i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.BaseRequestBuilder
}
// ItemEventsPublicRequestBuilderGetQueryParameters list public events for a user
// ItemEventsPublicRequestBuilderGetQueryParameters > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
type ItemEventsPublicRequestBuilderGetQueryParameters struct {
// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/[email protected]/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
Page *int32 `uriparametername:"page"`
Expand All @@ -30,7 +30,7 @@ func NewItemEventsPublicRequestBuilder(rawUrl string, requestAdapter i2ae4187f7d
urlParams["request-raw-url"] = rawUrl
return NewItemEventsPublicRequestBuilderInternal(urlParams, requestAdapter)
}
// Get list public events for a user
// Get > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
// returns a []Eventable when successful
// [API method documentation]
//
Expand All @@ -52,6 +52,7 @@ func (m *ItemEventsPublicRequestBuilder) Get(ctx context.Context, requestConfigu
}
return val, nil
}
// ToGetRequestInformation > [!NOTE]> This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
// returns a *RequestInformation when successful
func (m *ItemEventsPublicRequestBuilder) ToGetRequestInformation(ctx context.Context, requestConfiguration *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestConfiguration[ItemEventsPublicRequestBuilderGetQueryParameters])(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) {
requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.GET, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters)
Expand Down
Loading

0 comments on commit 893da72

Please sign in to comment.