Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds code_security_configuration (repository, status), updates item_repo_item_request_builder (CodeSecurityConfiguration) #100

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "2999CDF1987B59F5D80BA1DDAE2101B1E0816453F99E08383F7693E0D0F951676313BC1AAD9B99397278CF58ADCD38995C4942BBEBBAD3FB9763D531973C3E02",
"descriptionHash": "DE5F98C38ECED98D5584742BA57E5A4EEA75FB123B6EF6A8021C5C19974B56AB0EEB75E1D7E95381BEC1659E2E5AFB54B01F08415E091D6F17C4962867C7C64F",
"descriptionLocation": "../../../../../schemas/api.github.com.json",
"lockFileVersion": "1.0.0",
"kiotaVersion": "1.14.0",
Expand Down
111 changes: 111 additions & 0 deletions pkg/github/models/code_security_configuration_for_repository.go
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)()
}
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
}
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);
}
5 changes: 5 additions & 0 deletions pkg/github/repos/item_repo_item_request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func (m *ItemRepoItemRequestBuilder) Codeowners()(*ItemItemCodeownersRequestBuil
func (m *ItemRepoItemRequestBuilder) CodeScanning()(*ItemItemCodeScanningRequestBuilder) {
return NewItemItemCodeScanningRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)
}
// CodeSecurityConfiguration the codeSecurityConfiguration property
// returns a *ItemItemCodeSecurityConfigurationRequestBuilder when successful
func (m *ItemRepoItemRequestBuilder) CodeSecurityConfiguration()(*ItemItemCodeSecurityConfigurationRequestBuilder) {
return NewItemItemCodeSecurityConfigurationRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)
}
// Codespaces the codespaces property
// returns a *ItemItemCodespacesRequestBuilder when successful
func (m *ItemRepoItemRequestBuilder) Codespaces()(*ItemItemCodespacesRequestBuilder) {
Expand Down
Loading