-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds code_security_configuration (repository, status), updates …
…item_repo_item_request_builder (CodeSecurityConfiguration)
- Loading branch information
1 parent
a26e8d9
commit af38674
Showing
5 changed files
with
235 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
pkg/github/models/code_security_configuration_for_repository.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package models | ||
|
||
import ( | ||
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" | ||
) | ||
|
||
// CodeSecurityConfigurationForRepository code security configuration associated with a repository and attachment status | ||
type CodeSecurityConfigurationForRepository struct { | ||
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. | ||
additionalData map[string]any | ||
// A code security configuration | ||
configuration CodeSecurityConfigurationable | ||
// The attachment status of the code security configuration on the repository. | ||
status *CodeSecurityConfigurationForRepository_status | ||
} | ||
// NewCodeSecurityConfigurationForRepository instantiates a new CodeSecurityConfigurationForRepository and sets the default values. | ||
func NewCodeSecurityConfigurationForRepository()(*CodeSecurityConfigurationForRepository) { | ||
m := &CodeSecurityConfigurationForRepository{ | ||
} | ||
m.SetAdditionalData(make(map[string]any)) | ||
return m | ||
} | ||
// CreateCodeSecurityConfigurationForRepositoryFromDiscriminatorValue creates a new instance of the appropriate class based on discriminator value | ||
// returns a Parsable when successful | ||
func CreateCodeSecurityConfigurationForRepositoryFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) { | ||
return NewCodeSecurityConfigurationForRepository(), nil | ||
} | ||
// GetAdditionalData gets the AdditionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. | ||
// returns a map[string]any when successful | ||
func (m *CodeSecurityConfigurationForRepository) GetAdditionalData()(map[string]any) { | ||
return m.additionalData | ||
} | ||
// GetConfiguration gets the configuration property value. A code security configuration | ||
// returns a CodeSecurityConfigurationable when successful | ||
func (m *CodeSecurityConfigurationForRepository) GetConfiguration()(CodeSecurityConfigurationable) { | ||
return m.configuration | ||
} | ||
// GetFieldDeserializers the deserialization information for the current model | ||
// returns a map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error) when successful | ||
func (m *CodeSecurityConfigurationForRepository) GetFieldDeserializers()(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error)) { | ||
res := make(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error)) | ||
res["configuration"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { | ||
val, err := n.GetObjectValue(CreateCodeSecurityConfigurationFromDiscriminatorValue) | ||
if err != nil { | ||
return err | ||
} | ||
if val != nil { | ||
m.SetConfiguration(val.(CodeSecurityConfigurationable)) | ||
} | ||
return nil | ||
} | ||
res["status"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { | ||
val, err := n.GetEnumValue(ParseCodeSecurityConfigurationForRepository_status) | ||
if err != nil { | ||
return err | ||
} | ||
if val != nil { | ||
m.SetStatus(val.(*CodeSecurityConfigurationForRepository_status)) | ||
} | ||
return nil | ||
} | ||
return res | ||
} | ||
// GetStatus gets the status property value. The attachment status of the code security configuration on the repository. | ||
// returns a *CodeSecurityConfigurationForRepository_status when successful | ||
func (m *CodeSecurityConfigurationForRepository) GetStatus()(*CodeSecurityConfigurationForRepository_status) { | ||
return m.status | ||
} | ||
// Serialize serializes information the current object | ||
func (m *CodeSecurityConfigurationForRepository) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) { | ||
{ | ||
err := writer.WriteObjectValue("configuration", m.GetConfiguration()) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
if m.GetStatus() != nil { | ||
cast := (*m.GetStatus()).String() | ||
err := writer.WriteStringValue("status", &cast) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
{ | ||
err := writer.WriteAdditionalData(m.GetAdditionalData()) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
// SetAdditionalData sets the AdditionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. | ||
func (m *CodeSecurityConfigurationForRepository) SetAdditionalData(value map[string]any)() { | ||
m.additionalData = value | ||
} | ||
// SetConfiguration sets the configuration property value. A code security configuration | ||
func (m *CodeSecurityConfigurationForRepository) SetConfiguration(value CodeSecurityConfigurationable)() { | ||
m.configuration = value | ||
} | ||
// SetStatus sets the status property value. The attachment status of the code security configuration on the repository. | ||
func (m *CodeSecurityConfigurationForRepository) SetStatus(value *CodeSecurityConfigurationForRepository_status)() { | ||
m.status = value | ||
} | ||
type CodeSecurityConfigurationForRepositoryable interface { | ||
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.AdditionalDataHolder | ||
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable | ||
GetConfiguration()(CodeSecurityConfigurationable) | ||
GetStatus()(*CodeSecurityConfigurationForRepository_status) | ||
SetConfiguration(value CodeSecurityConfigurationable)() | ||
SetStatus(value *CodeSecurityConfigurationForRepository_status)() | ||
} |
55 changes: 55 additions & 0 deletions
55
pkg/github/models/code_security_configuration_for_repository_status.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package models | ||
import ( | ||
"errors" | ||
) | ||
// The attachment status of the code security configuration on the repository. | ||
type CodeSecurityConfigurationForRepository_status int | ||
|
||
const ( | ||
ATTACHED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS CodeSecurityConfigurationForRepository_status = iota | ||
ATTACHING_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
DETACHED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
REMOVED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
ENFORCED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
FAILED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
UPDATING_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
REMOVED_BY_ENTERPRISE_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
) | ||
|
||
func (i CodeSecurityConfigurationForRepository_status) String() string { | ||
return []string{"attached", "attaching", "detached", "removed", "enforced", "failed", "updating", "removed_by_enterprise"}[i] | ||
} | ||
func ParseCodeSecurityConfigurationForRepository_status(v string) (any, error) { | ||
result := ATTACHED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
switch v { | ||
case "attached": | ||
result = ATTACHED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
case "attaching": | ||
result = ATTACHING_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
case "detached": | ||
result = DETACHED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
case "removed": | ||
result = REMOVED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
case "enforced": | ||
result = ENFORCED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
case "failed": | ||
result = FAILED_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
case "updating": | ||
result = UPDATING_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
case "removed_by_enterprise": | ||
result = REMOVED_BY_ENTERPRISE_CODESECURITYCONFIGURATIONFORREPOSITORY_STATUS | ||
default: | ||
return 0, errors.New("Unknown CodeSecurityConfigurationForRepository_status value: " + v) | ||
} | ||
return &result, nil | ||
} | ||
func SerializeCodeSecurityConfigurationForRepository_status(values []CodeSecurityConfigurationForRepository_status) []string { | ||
result := make([]string, len(values)) | ||
for i, v := range values { | ||
result[i] = v.String() | ||
} | ||
return result | ||
} | ||
func (i CodeSecurityConfigurationForRepository_status) isMultiValue() bool { | ||
return false | ||
} |
63 changes: 63 additions & 0 deletions
63
pkg/github/repos/item_item_code_security_configuration_request_builder.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package repos | ||
|
||
import ( | ||
"context" | ||
i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f "github.com/microsoft/kiota-abstractions-go" | ||
i59ea7d99994c6a4bb9ef742ed717844297d055c7fd3742131406eea67a6404b6 "github.com/octokit/go-sdk/pkg/github/models" | ||
) | ||
|
||
// ItemItemCodeSecurityConfigurationRequestBuilder builds and executes requests for operations under \repos\{owner-id}\{repo-id}\code-security-configuration | ||
type ItemItemCodeSecurityConfigurationRequestBuilder struct { | ||
i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.BaseRequestBuilder | ||
} | ||
// NewItemItemCodeSecurityConfigurationRequestBuilderInternal instantiates a new ItemItemCodeSecurityConfigurationRequestBuilder and sets the default values. | ||
func NewItemItemCodeSecurityConfigurationRequestBuilderInternal(pathParameters map[string]string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*ItemItemCodeSecurityConfigurationRequestBuilder) { | ||
m := &ItemItemCodeSecurityConfigurationRequestBuilder{ | ||
BaseRequestBuilder: *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewBaseRequestBuilder(requestAdapter, "{+baseurl}/repos/{owner%2Did}/{repo%2Did}/code-security-configuration", pathParameters), | ||
} | ||
return m | ||
} | ||
// NewItemItemCodeSecurityConfigurationRequestBuilder instantiates a new ItemItemCodeSecurityConfigurationRequestBuilder and sets the default values. | ||
func NewItemItemCodeSecurityConfigurationRequestBuilder(rawUrl string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*ItemItemCodeSecurityConfigurationRequestBuilder) { | ||
urlParams := make(map[string]string) | ||
urlParams["request-raw-url"] = rawUrl | ||
return NewItemItemCodeSecurityConfigurationRequestBuilderInternal(urlParams, requestAdapter) | ||
} | ||
// Get get the code security configuration that manages a repository's code security settings.The authenticated user must be an administrator or security manager for the organization to use this endpoint.OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. | ||
// returns a CodeSecurityConfigurationForRepositoryable 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 | ||
// [API method documentation] | ||
// | ||
// [API method documentation]: https://docs.github.com/rest/code-security/configurations#get-the-code-security-configuration-associated-with-a-repository | ||
func (m *ItemItemCodeSecurityConfigurationRequestBuilder) Get(ctx context.Context, requestConfiguration *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestConfiguration[i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.DefaultQueryParameters])(i59ea7d99994c6a4bb9ef742ed717844297d055c7fd3742131406eea67a6404b6.CodeSecurityConfigurationForRepositoryable, error) { | ||
requestInfo, err := m.ToGetRequestInformation(ctx, requestConfiguration); | ||
if err != nil { | ||
return nil, err | ||
} | ||
errorMapping := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.ErrorMappings { | ||
"403": i59ea7d99994c6a4bb9ef742ed717844297d055c7fd3742131406eea67a6404b6.CreateBasicErrorFromDiscriminatorValue, | ||
"404": i59ea7d99994c6a4bb9ef742ed717844297d055c7fd3742131406eea67a6404b6.CreateBasicErrorFromDiscriminatorValue, | ||
} | ||
res, err := m.BaseRequestBuilder.RequestAdapter.Send(ctx, requestInfo, i59ea7d99994c6a4bb9ef742ed717844297d055c7fd3742131406eea67a6404b6.CreateCodeSecurityConfigurationForRepositoryFromDiscriminatorValue, errorMapping) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if res == nil { | ||
return nil, nil | ||
} | ||
return res.(i59ea7d99994c6a4bb9ef742ed717844297d055c7fd3742131406eea67a6404b6.CodeSecurityConfigurationForRepositoryable), nil | ||
} | ||
// ToGetRequestInformation get the code security configuration that manages a repository's code security settings.The authenticated user must be an administrator or security manager for the organization to use this endpoint.OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. | ||
// returns a *RequestInformation when successful | ||
func (m *ItemItemCodeSecurityConfigurationRequestBuilder) ToGetRequestInformation(ctx context.Context, requestConfiguration *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestConfiguration[i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.DefaultQueryParameters])(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) { | ||
requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.GET, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters) | ||
i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.ConfigureRequestInformation(requestInfo, requestConfiguration) | ||
requestInfo.Headers.TryAdd("Accept", "application/json") | ||
return requestInfo, nil | ||
} | ||
// WithUrl returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. | ||
// returns a *ItemItemCodeSecurityConfigurationRequestBuilder when successful | ||
func (m *ItemItemCodeSecurityConfigurationRequestBuilder) WithUrl(rawUrl string)(*ItemItemCodeSecurityConfigurationRequestBuilder) { | ||
return NewItemItemCodeSecurityConfigurationRequestBuilder(rawUrl, m.BaseRequestBuilder.RequestAdapter); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters