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 Oct 8, 2024
1 parent fb7cb7c commit cfe5819
Show file tree
Hide file tree
Showing 8 changed files with 2,445 additions and 2,458 deletions.
4 changes: 4 additions & 0 deletions pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func NewApiClient(optionFuncs ...ClientOptionFunc) (*Client, error) {
return nil, fmt.Errorf("failed to create transport from GitHub App: %v", err)
}

if options.BaseURL != "" {
appTransport.BaseURL = options.BaseURL
}

netHttpClient.Transport = appTransport
}

Expand Down
49 changes: 49 additions & 0 deletions pkg/client_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package pkg

import (
"context"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"

abs "github.com/microsoft/kiota-abstractions-go"
"github.com/octokit/go-sdk-enterprise-cloud/pkg/github/installation"
"github.com/octokit/go-sdk-enterprise-cloud/pkg/headers"
)

Expand Down Expand Up @@ -91,6 +97,49 @@ func TestNewApiClientAppAuthHappyPath(t *testing.T) {
}
}

func TestNewApiClientAppAuthBaseUrl(t *testing.T) {
tmpfile, err := os.CreateTemp("", pemFileName)
if err != nil {
t.Fatal(err)
}
defer os.Remove(tmpfile.Name())

if _, err := tmpfile.Write(key); err != nil {
t.Fatal(err)
}
if err := tmpfile.Close(); err != nil {
t.Fatal(err)
}

expectedCall := false
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.Contains(r.URL.Path, "/app/installations") {
expectedCall = true
}
}))

client, err := NewApiClient(
WithGitHubAppAuthentication(tmpfile.Name(), clientID, installationID),
WithBaseUrl(server.URL),
)
if err != nil {
t.Fatalf("error creating client: %v", err)
}
if client == nil {
t.Fatalf("client is nil")
}
queryParams := &installation.RepositoriesRequestBuilderGetQueryParameters{}
requestConfig := &abs.RequestConfiguration[installation.RepositoriesRequestBuilderGetQueryParameters]{
QueryParameters: queryParams,
}

// trigger a refresh of the installation token to the expected url
_, _ = client.Installation().Repositories().Get(context.Background(), requestConfig)
if !expectedCall {
t.Errorf("installation token endpoint not called")
}
}

func TestNewApiClientAppAuthErrorGettingKeyFromFile(t *testing.T) {
client, err := NewApiClient(WithGitHubAppAuthentication("pem/file/does/not/exist.pem", clientID, installationID))
if err == nil {
Expand Down
4,714 changes: 2,257 additions & 2,457 deletions pkg/github/.kiota.log

Large diffs are not rendered by default.

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": "8E75A9568025D2342D8E3EED133A8A20DAA06C7979A39C420CB0C607E9E357E71B605AC9F7C811E24985B6C4902845A6C94C831F79C3EB687B4BC744DDB5C5FF",
"descriptionHash": "78E960D62E4977D7C0590CFB9F19215F0D810ACA39F64862C52E2D17758BE492D45635B01CC02DDA49AB89ABB9688B3996719F5A57DEF299897C71D6436F4F66",
"descriptionLocation": "../../../../../schemas/ghec.json",
"lockFileVersion": "1.0.0",
"kiotaVersion": "1.19.0",
Expand Down
30 changes: 30 additions & 0 deletions pkg/github/models/copilot_organization_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type CopilotOrganizationDetails struct {
cli *CopilotOrganizationDetails_cli
// The organization policy for allowing or disallowing organization members to use Copilot Chat within their editor.
ide_chat *CopilotOrganizationDetails_ide_chat
// The Copilot plan of the organization, or the parent enterprise, when applicable.
plan_type *CopilotOrganizationDetails_plan_type
// The organization policy for allowing or disallowing organization members to use Copilot features within github.com.
platform_chat *CopilotOrganizationDetails_platform_chat
// The organization policy for allowing or disallowing Copilot to make suggestions that match public code.
Expand Down Expand Up @@ -67,6 +69,16 @@ func (m *CopilotOrganizationDetails) GetFieldDeserializers()(map[string]func(i87
}
return nil
}
res["plan_type"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
val, err := n.GetEnumValue(ParseCopilotOrganizationDetails_plan_type)
if err != nil {
return err
}
if val != nil {
m.SetPlanType(val.(*CopilotOrganizationDetails_plan_type))
}
return nil
}
res["platform_chat"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
val, err := n.GetEnumValue(ParseCopilotOrganizationDetails_platform_chat)
if err != nil {
Expand Down Expand Up @@ -114,6 +126,11 @@ func (m *CopilotOrganizationDetails) GetFieldDeserializers()(map[string]func(i87
func (m *CopilotOrganizationDetails) GetIdeChat()(*CopilotOrganizationDetails_ide_chat) {
return m.ide_chat
}
// GetPlanType gets the plan_type property value. The Copilot plan of the organization, or the parent enterprise, when applicable.
// returns a *CopilotOrganizationDetails_plan_type when successful
func (m *CopilotOrganizationDetails) GetPlanType()(*CopilotOrganizationDetails_plan_type) {
return m.plan_type
}
// GetPlatformChat gets the platform_chat property value. The organization policy for allowing or disallowing organization members to use Copilot features within github.com.
// returns a *CopilotOrganizationDetails_platform_chat when successful
func (m *CopilotOrganizationDetails) GetPlatformChat()(*CopilotOrganizationDetails_platform_chat) {
Expand Down Expand Up @@ -150,6 +167,13 @@ func (m *CopilotOrganizationDetails) Serialize(writer i878a80d2330e89d26896388a3
return err
}
}
if m.GetPlanType() != nil {
cast := (*m.GetPlanType()).String()
err := writer.WriteStringValue("plan_type", &cast)
if err != nil {
return err
}
}
if m.GetPlatformChat() != nil {
cast := (*m.GetPlatformChat()).String()
err := writer.WriteStringValue("platform_chat", &cast)
Expand Down Expand Up @@ -197,6 +221,10 @@ func (m *CopilotOrganizationDetails) SetCli(value *CopilotOrganizationDetails_cl
func (m *CopilotOrganizationDetails) SetIdeChat(value *CopilotOrganizationDetails_ide_chat)() {
m.ide_chat = value
}
// SetPlanType sets the plan_type property value. The Copilot plan of the organization, or the parent enterprise, when applicable.
func (m *CopilotOrganizationDetails) SetPlanType(value *CopilotOrganizationDetails_plan_type)() {
m.plan_type = value
}
// SetPlatformChat sets the platform_chat property value. The organization policy for allowing or disallowing organization members to use Copilot features within github.com.
func (m *CopilotOrganizationDetails) SetPlatformChat(value *CopilotOrganizationDetails_platform_chat)() {
m.platform_chat = value
Expand All @@ -218,12 +246,14 @@ type CopilotOrganizationDetailsable interface {
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable
GetCli()(*CopilotOrganizationDetails_cli)
GetIdeChat()(*CopilotOrganizationDetails_ide_chat)
GetPlanType()(*CopilotOrganizationDetails_plan_type)
GetPlatformChat()(*CopilotOrganizationDetails_platform_chat)
GetPublicCodeSuggestions()(*CopilotOrganizationDetails_public_code_suggestions)
GetSeatBreakdown()(CopilotSeatBreakdownable)
GetSeatManagementSetting()(*CopilotOrganizationDetails_seat_management_setting)
SetCli(value *CopilotOrganizationDetails_cli)()
SetIdeChat(value *CopilotOrganizationDetails_ide_chat)()
SetPlanType(value *CopilotOrganizationDetails_plan_type)()
SetPlatformChat(value *CopilotOrganizationDetails_platform_chat)()
SetPublicCodeSuggestions(value *CopilotOrganizationDetails_public_code_suggestions)()
SetSeatBreakdown(value CopilotSeatBreakdownable)()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package models
// The Copilot plan of the organization, or the parent enterprise, when applicable.
type CopilotOrganizationDetails_plan_type int

const (
BUSINESS_COPILOTORGANIZATIONDETAILS_PLAN_TYPE CopilotOrganizationDetails_plan_type = iota
ENTERPRISE_COPILOTORGANIZATIONDETAILS_PLAN_TYPE
UNKNOWN_COPILOTORGANIZATIONDETAILS_PLAN_TYPE
)

func (i CopilotOrganizationDetails_plan_type) String() string {
return []string{"business", "enterprise", "unknown"}[i]
}
func ParseCopilotOrganizationDetails_plan_type(v string) (any, error) {
result := BUSINESS_COPILOTORGANIZATIONDETAILS_PLAN_TYPE
switch v {
case "business":
result = BUSINESS_COPILOTORGANIZATIONDETAILS_PLAN_TYPE
case "enterprise":
result = ENTERPRISE_COPILOTORGANIZATIONDETAILS_PLAN_TYPE
case "unknown":
result = UNKNOWN_COPILOTORGANIZATIONDETAILS_PLAN_TYPE
default:
return nil, nil
}
return &result, nil
}
func SerializeCopilotOrganizationDetails_plan_type(values []CopilotOrganizationDetails_plan_type) []string {
result := make([]string, len(values))
for i, v := range values {
result[i] = v.String()
}
return result
}
func (i CopilotOrganizationDetails_plan_type) isMultiValue() bool {
return false
}
30 changes: 30 additions & 0 deletions pkg/github/models/copilot_seat_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type CopilotSeatDetails struct {
organization NullableOrganizationSimpleable
// The pending cancellation date for the seat, in `YYYY-MM-DD` format. This will be null unless the assignee's Copilot access has been canceled during the current billing cycle. If the seat has been cancelled, this corresponds to the start of the organization's next billing cycle.
pending_cancellation_date *i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.DateOnly
// The Copilot plan of the organization, or the parent enterprise, when applicable.
plan_type *CopilotSeatDetails_plan_type
// Timestamp of when the assignee's GitHub Copilot access was last updated, in ISO 8601 format.
updated_at *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time
}
Expand Down Expand Up @@ -207,6 +209,16 @@ func (m *CopilotSeatDetails) GetFieldDeserializers()(map[string]func(i878a80d233
}
return nil
}
res["plan_type"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
val, err := n.GetEnumValue(ParseCopilotSeatDetails_plan_type)
if err != nil {
return err
}
if val != nil {
m.SetPlanType(val.(*CopilotSeatDetails_plan_type))
}
return nil
}
res["updated_at"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
val, err := n.GetTimeValue()
if err != nil {
Expand Down Expand Up @@ -239,6 +251,11 @@ func (m *CopilotSeatDetails) GetOrganization()(NullableOrganizationSimpleable) {
func (m *CopilotSeatDetails) GetPendingCancellationDate()(*i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.DateOnly) {
return m.pending_cancellation_date
}
// GetPlanType gets the plan_type property value. The Copilot plan of the organization, or the parent enterprise, when applicable.
// returns a *CopilotSeatDetails_plan_type when successful
func (m *CopilotSeatDetails) GetPlanType()(*CopilotSeatDetails_plan_type) {
return m.plan_type
}
// GetUpdatedAt gets the updated_at property value. Timestamp of when the assignee's GitHub Copilot access was last updated, in ISO 8601 format.
// returns a *Time when successful
func (m *CopilotSeatDetails) GetUpdatedAt()(*i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time) {
Expand Down Expand Up @@ -288,6 +305,13 @@ func (m *CopilotSeatDetails) Serialize(writer i878a80d2330e89d26896388a3f487eef2
return err
}
}
if m.GetPlanType() != nil {
cast := (*m.GetPlanType()).String()
err := writer.WriteStringValue("plan_type", &cast)
if err != nil {
return err
}
}
{
err := writer.WriteTimeValue("updated_at", m.GetUpdatedAt())
if err != nil {
Expand Down Expand Up @@ -324,6 +348,10 @@ func (m *CopilotSeatDetails) SetOrganization(value NullableOrganizationSimpleabl
func (m *CopilotSeatDetails) SetPendingCancellationDate(value *i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.DateOnly)() {
m.pending_cancellation_date = value
}
// SetPlanType sets the plan_type property value. The Copilot plan of the organization, or the parent enterprise, when applicable.
func (m *CopilotSeatDetails) SetPlanType(value *CopilotSeatDetails_plan_type)() {
m.plan_type = value
}
// SetUpdatedAt sets the updated_at property value. Timestamp of when the assignee's GitHub Copilot access was last updated, in ISO 8601 format.
func (m *CopilotSeatDetails) SetUpdatedAt(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time)() {
m.updated_at = value
Expand All @@ -337,6 +365,7 @@ type CopilotSeatDetailsable interface {
GetLastActivityEditor()(*string)
GetOrganization()(NullableOrganizationSimpleable)
GetPendingCancellationDate()(*i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.DateOnly)
GetPlanType()(*CopilotSeatDetails_plan_type)
GetUpdatedAt()(*i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time)
SetAssignee(value SimpleUserable)()
SetAssigningTeam(value CopilotSeatDetails_CopilotSeatDetails_assigning_teamable)()
Expand All @@ -345,5 +374,6 @@ type CopilotSeatDetailsable interface {
SetLastActivityEditor(value *string)()
SetOrganization(value NullableOrganizationSimpleable)()
SetPendingCancellationDate(value *i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.DateOnly)()
SetPlanType(value *CopilotSeatDetails_plan_type)()
SetUpdatedAt(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time)()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package models
// The Copilot plan of the organization, or the parent enterprise, when applicable.
type CopilotSeatDetails_plan_type int

const (
BUSINESS_COPILOTSEATDETAILS_PLAN_TYPE CopilotSeatDetails_plan_type = iota
ENTERPRISE_COPILOTSEATDETAILS_PLAN_TYPE
UNKNOWN_COPILOTSEATDETAILS_PLAN_TYPE
)

func (i CopilotSeatDetails_plan_type) String() string {
return []string{"business", "enterprise", "unknown"}[i]
}
func ParseCopilotSeatDetails_plan_type(v string) (any, error) {
result := BUSINESS_COPILOTSEATDETAILS_PLAN_TYPE
switch v {
case "business":
result = BUSINESS_COPILOTSEATDETAILS_PLAN_TYPE
case "enterprise":
result = ENTERPRISE_COPILOTSEATDETAILS_PLAN_TYPE
case "unknown":
result = UNKNOWN_COPILOTSEATDETAILS_PLAN_TYPE
default:
return nil, nil
}
return &result, nil
}
func SerializeCopilotSeatDetails_plan_type(values []CopilotSeatDetails_plan_type) []string {
result := make([]string, len(values))
for i, v := range values {
result[i] = v.String()
}
return result
}
func (i CopilotSeatDetails_plan_type) isMultiValue() bool {
return false
}

0 comments on commit cfe5819

Please sign in to comment.