From 3e8041dde616bb127fa27fb3643287805c25e147 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:38:52 +0000 Subject: [PATCH] Add /api/v2/org_configs specs (#2531) Co-authored-by: ci.datadog-api-spec Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 196 ++++++++++++++ api/datadogV2/api_organizations.go | 216 ++++++++++++++++ api/datadogV2/doc.go | 3 + .../model_org_config_get_response.go | 110 ++++++++ .../model_org_config_list_response.go | 101 ++++++++ api/datadogV2/model_org_config_read.go | 178 +++++++++++++ .../model_org_config_read_attributes.go | 244 ++++++++++++++++++ api/datadogV2/model_org_config_type.go | 64 +++++ api/datadogV2/model_org_config_write.go | 146 +++++++++++ .../model_org_config_write_attributes.go | 101 ++++++++ .../model_org_config_write_request.go | 110 ++++++++ examples/v2/organizations/GetOrgConfig.go | 29 +++ examples/v2/organizations/ListOrgConfigs.go | 29 +++ examples/v2/organizations/UpdateOrgConfig.go | 37 +++ tests/scenarios/api_mappings.go | 2 +- ...ig_value_returns_Not_Found_response.freeze | 1 + ...nfig_value_returns_Not_Found_response.yaml | 19 ++ ...rg_Config_value_returns_OK_response.freeze | 1 + ..._Org_Config_value_returns_OK_response.yaml | 22 ++ ...ist_Org_Configs_returns_OK_response.freeze | 1 + ..._List_Org_Configs_returns_OK_response.yaml | 42 +++ ...Config_returns_Bad_Request_response.freeze | 1 + ...g_Config_returns_Bad_Request_response.yaml | 23 ++ ...g_Config_returns_Not_Found_response.freeze | 1 + ...Org_Config_returns_Not_Found_response.yaml | 22 ++ ...ific_Org_Config_returns_OK_response.freeze | 1 + ...ecific_Org_Config_returns_OK_response.yaml | 25 ++ .../features/v2/organizations.feature | 65 ++++- tests/scenarios/features/v2/undo.json | 18 ++ 30 files changed, 1808 insertions(+), 8 deletions(-) create mode 100644 api/datadogV2/model_org_config_get_response.go create mode 100644 api/datadogV2/model_org_config_list_response.go create mode 100644 api/datadogV2/model_org_config_read.go create mode 100644 api/datadogV2/model_org_config_read_attributes.go create mode 100644 api/datadogV2/model_org_config_type.go create mode 100644 api/datadogV2/model_org_config_write.go create mode 100644 api/datadogV2/model_org_config_write_attributes.go create mode 100644 api/datadogV2/model_org_config_write_request.go create mode 100644 examples/v2/organizations/GetOrgConfig.go create mode 100644 examples/v2/organizations/ListOrgConfigs.go create mode 100644 examples/v2/organizations/UpdateOrgConfig.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_Not_Found_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_Not_Found_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_List_Org_Configs_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_List_Org_Configs_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Not_Found_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Not_Found_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_OK_response.yaml diff --git a/.apigentools-info b/.apigentools-info index 69e6282e756..778263a52b1 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-06-17 09:21:30.436144", - "spec_repo_commit": "743cf92b" + "regenerated": "2024-06-18 16:37:22.237275", + "spec_repo_commit": "848af7a9" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-06-17 09:21:30.454502", - "spec_repo_commit": "743cf92b" + "regenerated": "2024-06-18 16:37:22.255405", + "spec_repo_commit": "848af7a9" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 7d45c6982de..76b6b541b1d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -373,6 +373,14 @@ components: required: true schema: type: string + OrgConfigName: + description: The name of an Org Config. + in: path + name: org_config_name + required: true + schema: + example: monitor_timezone + type: string PageNumber: description: Specific page number to return. in: query @@ -13822,6 +13830,104 @@ components: required: - data type: object + OrgConfigGetResponse: + description: A response with a single Org Config. + properties: + data: + $ref: '#/components/schemas/OrgConfigRead' + required: + - data + type: object + OrgConfigListResponse: + description: A response with multiple Org Configs. + properties: + data: + description: An array of Org Configs. + items: + $ref: '#/components/schemas/OrgConfigRead' + type: array + required: + - data + type: object + OrgConfigRead: + description: A single Org Config. + properties: + attributes: + $ref: '#/components/schemas/OrgConfigReadAttributes' + id: + description: A unique identifier for an Org Config. + example: abcd1234 + type: string + type: + $ref: '#/components/schemas/OrgConfigType' + required: + - id + - type + - attributes + type: object + OrgConfigReadAttributes: + description: Readable attributes of an Org Config. + properties: + description: + description: The description of an Org Config. + example: Frobulate the turbo encabulator manifold + type: string + modified_at: + description: The timestamp of the last Org Config update (if any). + format: date-time + nullable: true + type: string + name: + description: The machine-friendly name of an Org Config. + example: monitor_timezone + type: string + value: + description: The value of an Org Config. + value_type: + description: The type of an Org Config value. + example: bool + type: string + required: + - name + - description + - value_type + - value + type: object + OrgConfigType: + description: Data type of an Org Config. + enum: + - org_configs + example: org_configs + type: string + x-enum-varnames: + - ORG_CONFIGS + OrgConfigWrite: + description: An Org Config write operation. + properties: + attributes: + $ref: '#/components/schemas/OrgConfigWriteAttributes' + type: + $ref: '#/components/schemas/OrgConfigType' + required: + - type + - attributes + type: object + OrgConfigWriteAttributes: + description: Writable attributes of an Org Config. + properties: + value: + description: The value of an Org Config. + required: + - value + type: object + OrgConfigWriteRequest: + description: A request to update an Org Config. + properties: + data: + $ref: '#/components/schemas/OrgConfigWrite' + required: + - data + type: object Organization: description: Organization object. properties: @@ -30455,6 +30561,96 @@ paths: limitParam: page[limit] pageOffsetParam: page[offset] resultsPath: data + /api/v2/org_configs: + get: + description: Returns all Org Configs (name, description, and value). + operationId: ListOrgConfigs + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OrgConfigListResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List Org Configs + tags: + - Organizations + /api/v2/org_configs/{org_config_name}: + get: + description: Return the name, description, and value of a specific Org Config. + operationId: GetOrgConfig + parameters: + - $ref: '#/components/parameters/OrgConfigName' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OrgConfigGetResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get a specific Org Config value + tags: + - Organizations + patch: + description: Update the value of a specific Org Config. + operationId: UpdateOrgConfig + parameters: + - $ref: '#/components/parameters/OrgConfigName' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OrgConfigWriteRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OrgConfigGetResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - org_management + summary: Update a specific Org Config + tags: + - Organizations /api/v2/permissions: get: description: Returns a list of all permissions, including name, description, diff --git a/api/datadogV2/api_organizations.go b/api/datadogV2/api_organizations.go index 8a2ff71376d..8ac36228001 100644 --- a/api/datadogV2/api_organizations.go +++ b/api/datadogV2/api_organizations.go @@ -9,6 +9,7 @@ import ( _io "io" _nethttp "net/http" _neturl "net/url" + "strings" "github.com/DataDog/datadog-api-client-go/v2/api/datadog" ) @@ -16,6 +17,221 @@ import ( // OrganizationsApi service type type OrganizationsApi datadog.Service +// GetOrgConfig Get a specific Org Config value. +// Return the name, description, and value of a specific Org Config. +func (a *OrganizationsApi) GetOrgConfig(ctx _context.Context, orgConfigName string) (OrgConfigGetResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue OrgConfigGetResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.OrganizationsApi.GetOrgConfig") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/org_configs/{org_config_name}" + localVarPath = strings.Replace(localVarPath, "{"+"org_config_name"+"}", _neturl.PathEscape(datadog.ParameterToString(orgConfigName, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListOrgConfigs List Org Configs. +// Returns all Org Configs (name, description, and value). +func (a *OrganizationsApi) ListOrgConfigs(ctx _context.Context) (OrgConfigListResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue OrgConfigListResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.OrganizationsApi.ListOrgConfigs") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/org_configs" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// UpdateOrgConfig Update a specific Org Config. +// Update the value of a specific Org Config. +func (a *OrganizationsApi) UpdateOrgConfig(ctx _context.Context, orgConfigName string, body OrgConfigWriteRequest) (OrgConfigGetResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue OrgConfigGetResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.OrganizationsApi.UpdateOrgConfig") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/org_configs/{org_config_name}" + localVarPath = strings.Replace(localVarPath, "{"+"org_config_name"+"}", _neturl.PathEscape(datadog.ParameterToString(orgConfigName, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // UploadIdPMetadataOptionalParameters holds optional parameters for UploadIdPMetadata. type UploadIdPMetadataOptionalParameters struct { IdpFile *_io.Reader diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index b2d08a4a558..d98f3333db8 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -208,6 +208,9 @@ // - [OpsgenieIntegrationApi.GetOpsgenieService] // - [OpsgenieIntegrationApi.ListOpsgenieServices] // - [OpsgenieIntegrationApi.UpdateOpsgenieService] +// - [OrganizationsApi.GetOrgConfig] +// - [OrganizationsApi.ListOrgConfigs] +// - [OrganizationsApi.UpdateOrgConfig] // - [OrganizationsApi.UploadIdPMetadata] // - [PowerpackApi.CreatePowerpack] // - [PowerpackApi.DeletePowerpack] diff --git a/api/datadogV2/model_org_config_get_response.go b/api/datadogV2/model_org_config_get_response.go new file mode 100644 index 00000000000..43d02f28615 --- /dev/null +++ b/api/datadogV2/model_org_config_get_response.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OrgConfigGetResponse A response with a single Org Config. +type OrgConfigGetResponse struct { + // A single Org Config. + Data OrgConfigRead `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOrgConfigGetResponse instantiates a new OrgConfigGetResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewOrgConfigGetResponse(data OrgConfigRead) *OrgConfigGetResponse { + this := OrgConfigGetResponse{} + this.Data = data + return &this +} + +// NewOrgConfigGetResponseWithDefaults instantiates a new OrgConfigGetResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewOrgConfigGetResponseWithDefaults() *OrgConfigGetResponse { + this := OrgConfigGetResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *OrgConfigGetResponse) GetData() OrgConfigRead { + if o == nil { + var ret OrgConfigRead + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *OrgConfigGetResponse) GetDataOk() (*OrgConfigRead, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *OrgConfigGetResponse) SetData(v OrgConfigRead) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OrgConfigGetResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OrgConfigGetResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *OrgConfigRead `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_org_config_list_response.go b/api/datadogV2/model_org_config_list_response.go new file mode 100644 index 00000000000..cc856840afb --- /dev/null +++ b/api/datadogV2/model_org_config_list_response.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OrgConfigListResponse A response with multiple Org Configs. +type OrgConfigListResponse struct { + // An array of Org Configs. + Data []OrgConfigRead `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOrgConfigListResponse instantiates a new OrgConfigListResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewOrgConfigListResponse(data []OrgConfigRead) *OrgConfigListResponse { + this := OrgConfigListResponse{} + this.Data = data + return &this +} + +// NewOrgConfigListResponseWithDefaults instantiates a new OrgConfigListResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewOrgConfigListResponseWithDefaults() *OrgConfigListResponse { + this := OrgConfigListResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *OrgConfigListResponse) GetData() []OrgConfigRead { + if o == nil { + var ret []OrgConfigRead + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *OrgConfigListResponse) GetDataOk() (*[]OrgConfigRead, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *OrgConfigListResponse) SetData(v []OrgConfigRead) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OrgConfigListResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OrgConfigListResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]OrgConfigRead `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_org_config_read.go b/api/datadogV2/model_org_config_read.go new file mode 100644 index 00000000000..345ba93157b --- /dev/null +++ b/api/datadogV2/model_org_config_read.go @@ -0,0 +1,178 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OrgConfigRead A single Org Config. +type OrgConfigRead struct { + // Readable attributes of an Org Config. + Attributes OrgConfigReadAttributes `json:"attributes"` + // A unique identifier for an Org Config. + Id string `json:"id"` + // Data type of an Org Config. + Type OrgConfigType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOrgConfigRead instantiates a new OrgConfigRead object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewOrgConfigRead(attributes OrgConfigReadAttributes, id string, typeVar OrgConfigType) *OrgConfigRead { + this := OrgConfigRead{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewOrgConfigReadWithDefaults instantiates a new OrgConfigRead object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewOrgConfigReadWithDefaults() *OrgConfigRead { + this := OrgConfigRead{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *OrgConfigRead) GetAttributes() OrgConfigReadAttributes { + if o == nil { + var ret OrgConfigReadAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *OrgConfigRead) GetAttributesOk() (*OrgConfigReadAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *OrgConfigRead) SetAttributes(v OrgConfigReadAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *OrgConfigRead) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *OrgConfigRead) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *OrgConfigRead) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *OrgConfigRead) GetType() OrgConfigType { + if o == nil { + var ret OrgConfigType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *OrgConfigRead) GetTypeOk() (*OrgConfigType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *OrgConfigRead) SetType(v OrgConfigType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OrgConfigRead) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OrgConfigRead) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *OrgConfigReadAttributes `json:"attributes"` + Id *string `json:"id"` + Type *OrgConfigType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_org_config_read_attributes.go b/api/datadogV2/model_org_config_read_attributes.go new file mode 100644 index 00000000000..43a72643336 --- /dev/null +++ b/api/datadogV2/model_org_config_read_attributes.go @@ -0,0 +1,244 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OrgConfigReadAttributes Readable attributes of an Org Config. +type OrgConfigReadAttributes struct { + // The description of an Org Config. + Description string `json:"description"` + // The timestamp of the last Org Config update (if any). + ModifiedAt datadog.NullableTime `json:"modified_at,omitempty"` + // The machine-friendly name of an Org Config. + Name string `json:"name"` + // The value of an Org Config. + Value interface{} `json:"value"` + // The type of an Org Config value. + ValueType string `json:"value_type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOrgConfigReadAttributes instantiates a new OrgConfigReadAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewOrgConfigReadAttributes(description string, name string, value interface{}, valueType string) *OrgConfigReadAttributes { + this := OrgConfigReadAttributes{} + this.Description = description + this.Name = name + this.Value = value + this.ValueType = valueType + return &this +} + +// NewOrgConfigReadAttributesWithDefaults instantiates a new OrgConfigReadAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewOrgConfigReadAttributesWithDefaults() *OrgConfigReadAttributes { + this := OrgConfigReadAttributes{} + return &this +} + +// GetDescription returns the Description field value. +func (o *OrgConfigReadAttributes) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *OrgConfigReadAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *OrgConfigReadAttributes) SetDescription(v string) { + o.Description = v +} + +// GetModifiedAt returns the ModifiedAt field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *OrgConfigReadAttributes) GetModifiedAt() time.Time { + if o == nil || o.ModifiedAt.Get() == nil { + var ret time.Time + return ret + } + return *o.ModifiedAt.Get() +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *OrgConfigReadAttributes) GetModifiedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.ModifiedAt.Get(), o.ModifiedAt.IsSet() +} + +// HasModifiedAt returns a boolean if a field has been set. +func (o *OrgConfigReadAttributes) HasModifiedAt() bool { + return o != nil && o.ModifiedAt.IsSet() +} + +// SetModifiedAt gets a reference to the given datadog.NullableTime and assigns it to the ModifiedAt field. +func (o *OrgConfigReadAttributes) SetModifiedAt(v time.Time) { + o.ModifiedAt.Set(&v) +} + +// SetModifiedAtNil sets the value for ModifiedAt to be an explicit nil. +func (o *OrgConfigReadAttributes) SetModifiedAtNil() { + o.ModifiedAt.Set(nil) +} + +// UnsetModifiedAt ensures that no value is present for ModifiedAt, not even an explicit nil. +func (o *OrgConfigReadAttributes) UnsetModifiedAt() { + o.ModifiedAt.Unset() +} + +// GetName returns the Name field value. +func (o *OrgConfigReadAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *OrgConfigReadAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *OrgConfigReadAttributes) SetName(v string) { + o.Name = v +} + +// GetValue returns the Value field value. +func (o *OrgConfigReadAttributes) GetValue() interface{} { + if o == nil { + var ret interface{} + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *OrgConfigReadAttributes) GetValueOk() (*interface{}, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *OrgConfigReadAttributes) SetValue(v interface{}) { + o.Value = v +} + +// GetValueType returns the ValueType field value. +func (o *OrgConfigReadAttributes) GetValueType() string { + if o == nil { + var ret string + return ret + } + return o.ValueType +} + +// GetValueTypeOk returns a tuple with the ValueType field value +// and a boolean to check if the value has been set. +func (o *OrgConfigReadAttributes) GetValueTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ValueType, true +} + +// SetValueType sets field value. +func (o *OrgConfigReadAttributes) SetValueType(v string) { + o.ValueType = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OrgConfigReadAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["description"] = o.Description + if o.ModifiedAt.IsSet() { + toSerialize["modified_at"] = o.ModifiedAt.Get() + } + toSerialize["name"] = o.Name + toSerialize["value"] = o.Value + toSerialize["value_type"] = o.ValueType + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OrgConfigReadAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description"` + ModifiedAt datadog.NullableTime `json:"modified_at,omitempty"` + Name *string `json:"name"` + Value *interface{} `json:"value"` + ValueType *string `json:"value_type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + if all.ValueType == nil { + return fmt.Errorf("required field value_type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "modified_at", "name", "value", "value_type"}) + } else { + return err + } + o.Description = *all.Description + o.ModifiedAt = all.ModifiedAt + o.Name = *all.Name + o.Value = *all.Value + o.ValueType = *all.ValueType + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_org_config_type.go b/api/datadogV2/model_org_config_type.go new file mode 100644 index 00000000000..e262980d7e1 --- /dev/null +++ b/api/datadogV2/model_org_config_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OrgConfigType Data type of an Org Config. +type OrgConfigType string + +// List of OrgConfigType. +const ( + ORGCONFIGTYPE_ORG_CONFIGS OrgConfigType = "org_configs" +) + +var allowedOrgConfigTypeEnumValues = []OrgConfigType{ + ORGCONFIGTYPE_ORG_CONFIGS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *OrgConfigType) GetAllowedValues() []OrgConfigType { + return allowedOrgConfigTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *OrgConfigType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = OrgConfigType(value) + return nil +} + +// NewOrgConfigTypeFromValue returns a pointer to a valid OrgConfigType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewOrgConfigTypeFromValue(v string) (*OrgConfigType, error) { + ev := OrgConfigType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for OrgConfigType: valid values are %v", v, allowedOrgConfigTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v OrgConfigType) IsValid() bool { + for _, existing := range allowedOrgConfigTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to OrgConfigType value. +func (v OrgConfigType) Ptr() *OrgConfigType { + return &v +} diff --git a/api/datadogV2/model_org_config_write.go b/api/datadogV2/model_org_config_write.go new file mode 100644 index 00000000000..6fb6be9af17 --- /dev/null +++ b/api/datadogV2/model_org_config_write.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OrgConfigWrite An Org Config write operation. +type OrgConfigWrite struct { + // Writable attributes of an Org Config. + Attributes OrgConfigWriteAttributes `json:"attributes"` + // Data type of an Org Config. + Type OrgConfigType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOrgConfigWrite instantiates a new OrgConfigWrite object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewOrgConfigWrite(attributes OrgConfigWriteAttributes, typeVar OrgConfigType) *OrgConfigWrite { + this := OrgConfigWrite{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewOrgConfigWriteWithDefaults instantiates a new OrgConfigWrite object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewOrgConfigWriteWithDefaults() *OrgConfigWrite { + this := OrgConfigWrite{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *OrgConfigWrite) GetAttributes() OrgConfigWriteAttributes { + if o == nil { + var ret OrgConfigWriteAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *OrgConfigWrite) GetAttributesOk() (*OrgConfigWriteAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *OrgConfigWrite) SetAttributes(v OrgConfigWriteAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *OrgConfigWrite) GetType() OrgConfigType { + if o == nil { + var ret OrgConfigType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *OrgConfigWrite) GetTypeOk() (*OrgConfigType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *OrgConfigWrite) SetType(v OrgConfigType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OrgConfigWrite) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OrgConfigWrite) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *OrgConfigWriteAttributes `json:"attributes"` + Type *OrgConfigType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_org_config_write_attributes.go b/api/datadogV2/model_org_config_write_attributes.go new file mode 100644 index 00000000000..40c4a8b5ed2 --- /dev/null +++ b/api/datadogV2/model_org_config_write_attributes.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OrgConfigWriteAttributes Writable attributes of an Org Config. +type OrgConfigWriteAttributes struct { + // The value of an Org Config. + Value interface{} `json:"value"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOrgConfigWriteAttributes instantiates a new OrgConfigWriteAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewOrgConfigWriteAttributes(value interface{}) *OrgConfigWriteAttributes { + this := OrgConfigWriteAttributes{} + this.Value = value + return &this +} + +// NewOrgConfigWriteAttributesWithDefaults instantiates a new OrgConfigWriteAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewOrgConfigWriteAttributesWithDefaults() *OrgConfigWriteAttributes { + this := OrgConfigWriteAttributes{} + return &this +} + +// GetValue returns the Value field value. +func (o *OrgConfigWriteAttributes) GetValue() interface{} { + if o == nil { + var ret interface{} + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *OrgConfigWriteAttributes) GetValueOk() (*interface{}, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value. +func (o *OrgConfigWriteAttributes) SetValue(v interface{}) { + o.Value = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OrgConfigWriteAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["value"] = o.Value + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OrgConfigWriteAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Value *interface{} `json:"value"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Value == nil { + return fmt.Errorf("required field value missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"value"}) + } else { + return err + } + o.Value = *all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_org_config_write_request.go b/api/datadogV2/model_org_config_write_request.go new file mode 100644 index 00000000000..94d3be64e62 --- /dev/null +++ b/api/datadogV2/model_org_config_write_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OrgConfigWriteRequest A request to update an Org Config. +type OrgConfigWriteRequest struct { + // An Org Config write operation. + Data OrgConfigWrite `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewOrgConfigWriteRequest instantiates a new OrgConfigWriteRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewOrgConfigWriteRequest(data OrgConfigWrite) *OrgConfigWriteRequest { + this := OrgConfigWriteRequest{} + this.Data = data + return &this +} + +// NewOrgConfigWriteRequestWithDefaults instantiates a new OrgConfigWriteRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewOrgConfigWriteRequestWithDefaults() *OrgConfigWriteRequest { + this := OrgConfigWriteRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *OrgConfigWriteRequest) GetData() OrgConfigWrite { + if o == nil { + var ret OrgConfigWrite + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *OrgConfigWriteRequest) GetDataOk() (*OrgConfigWrite, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *OrgConfigWriteRequest) SetData(v OrgConfigWrite) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OrgConfigWriteRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OrgConfigWriteRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *OrgConfigWrite `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/examples/v2/organizations/GetOrgConfig.go b/examples/v2/organizations/GetOrgConfig.go new file mode 100644 index 00000000000..b98930e5f3b --- /dev/null +++ b/examples/v2/organizations/GetOrgConfig.go @@ -0,0 +1,29 @@ +// Get a specific Org Config value returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewOrganizationsApi(apiClient) + resp, r, err := api.GetOrgConfig(ctx, "custom_roles") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OrganizationsApi.GetOrgConfig`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `OrganizationsApi.GetOrgConfig`:\n%s\n", responseContent) +} diff --git a/examples/v2/organizations/ListOrgConfigs.go b/examples/v2/organizations/ListOrgConfigs.go new file mode 100644 index 00000000000..b04ecc74f3a --- /dev/null +++ b/examples/v2/organizations/ListOrgConfigs.go @@ -0,0 +1,29 @@ +// List Org Configs returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewOrganizationsApi(apiClient) + resp, r, err := api.ListOrgConfigs(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OrganizationsApi.ListOrgConfigs`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `OrganizationsApi.ListOrgConfigs`:\n%s\n", responseContent) +} diff --git a/examples/v2/organizations/UpdateOrgConfig.go b/examples/v2/organizations/UpdateOrgConfig.go new file mode 100644 index 00000000000..97ed1d57240 --- /dev/null +++ b/examples/v2/organizations/UpdateOrgConfig.go @@ -0,0 +1,37 @@ +// Update a specific Org Config returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.OrgConfigWriteRequest{ + Data: datadogV2.OrgConfigWrite{ + Attributes: datadogV2.OrgConfigWriteAttributes{ + Value: "UTC", + }, + Type: datadogV2.ORGCONFIGTYPE_ORG_CONFIGS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewOrganizationsApi(apiClient) + resp, r, err := api.UpdateOrgConfig(ctx, "monitor_timezone", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OrganizationsApi.UpdateOrgConfig`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `OrganizationsApi.UpdateOrgConfig`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index da446004ea2..1ab20dc1789 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -75,6 +75,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "LogsMetricsApi": reflect.ValueOf(datadogV2.NewLogsMetricsApi), "MetricsApi": reflect.ValueOf(datadogV2.NewMetricsApi), "MonitorsApi": reflect.ValueOf(datadogV2.NewMonitorsApi), + "OrganizationsApi": reflect.ValueOf(datadogV2.NewOrganizationsApi), "RolesApi": reflect.ValueOf(datadogV2.NewRolesApi), "SecurityMonitoringApi": reflect.ValueOf(datadogV2.NewSecurityMonitoringApi), "PowerpackApi": reflect.ValueOf(datadogV2.NewPowerpackApi), @@ -82,7 +83,6 @@ var apiMappings = map[string]map[string]reflect.Value{ "CSMThreatsApi": reflect.ValueOf(datadogV2.NewCSMThreatsApi), "RestrictionPoliciesApi": reflect.ValueOf(datadogV2.NewRestrictionPoliciesApi), "RUMApi": reflect.ValueOf(datadogV2.NewRUMApi), - "OrganizationsApi": reflect.ValueOf(datadogV2.NewOrganizationsApi), "ServiceScorecardsApi": reflect.ValueOf(datadogV2.NewServiceScorecardsApi), "SensitiveDataScannerApi": reflect.ValueOf(datadogV2.NewSensitiveDataScannerApi), "ServiceAccountsApi": reflect.ValueOf(datadogV2.NewServiceAccountsApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..b8ca61f906a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2024-06-12T14:43:53.056Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..f923f069ff5 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_Not_Found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/org_configs/i_dont_exist + response: + body: '{"errors":["OrgConfig: i_dont_exist not found"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_OK_response.freeze new file mode 100644 index 00000000000..03b64c4edd7 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-06-12T14:43:53.592Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_OK_response.yaml new file mode 100644 index 00000000000..96fe5233914 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Get_a_specific_Org_Config_value_returns_OK_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/org_configs/custom_roles + response: + body: '{"data":{"type":"org_configs","id":"d4a6259b-5599-5120-8bdb-22718cb09118","attributes":{"name":"custom_roles","description":"Enables + the custom roles (RBAC) UI.","value_type":"bool","value":false,"modified_at":null}}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_List_Org_Configs_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_List_Org_Configs_returns_OK_response.freeze new file mode 100644 index 00000000000..e428c0dfd6c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_List_Org_Configs_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-06-12T14:43:54.065Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_List_Org_Configs_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_List_Org_Configs_returns_OK_response.yaml new file mode 100644 index 00000000000..f044968349c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_List_Org_Configs_returns_OK_response.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/org_configs + response: + body: '{"data":[{"type":"org_configs","id":"4c2b0cec-de6d-5030-b3fd-391b34ff99eb","attributes":{"name":"invalid_session_30_days","description":"Test + test test","value_type":"bool","value":true,"modified_at":null}},{"type":"org_configs","id":"ae6ea27d-7945-56c9-a12b-37fc3b094459","attributes":{"name":"my_new_org_config_key_name","description":"This + is a description","value_type":"bool","value":false,"modified_at":null}},{"type":"org_configs","id":"0e63d108-84c3-55c7-9767-e00b21e5bc30","attributes":{"name":"domain_allowlist","description":"domain + allowlist for emails to be sent","value_type":"email_domain_list","value":[],"modified_at":null}},{"type":"org_configs","id":"3081bbc5-6227-5e58-86e3-835fa2b72858","attributes":{"name":"enable_domain_allowlist","description":"domain + allowlist enablement for emails to be sent","value_type":"bool","value":false,"modified_at":null}},{"type":"org_configs","id":"86f9a647-f7f9-5181-aa4a-2530bdcb4374","attributes":{"name":"30d_invite_expiration","description":"This + will set the expiration date of Org invites to 30 days instead of the default + 2 days","value_type":"bool","value":false,"modified_at":null}},{"type":"org_configs","id":"5639dc2d-d96a-558a-b2bb-c563b5a7d609","attributes":{"name":"oauth_client_disallow_list","description":"Disallow + list for oauth clients users can authorize with in a given org.","value_type":"list","value":[],"modified_at":null}},{"type":"org_configs","id":"336c724c-521f-559e-9b43-28b38289ab64","attributes":{"name":"restrict_export_to_csv","description":"Disables + the ability to export Logs to CSV via the API and UI for all users of an org.","value_type":"bool","value":false,"modified_at":null}},{"type":"org_configs","id":"b2935166-5372-53a7-9c91-632d39c81dba","attributes":{"name":"pci_enabled","description":"pci + compliance is enabled for this org","value_type":"bool","value":false,"modified_at":null}},{"type":"org_configs","id":"bddab2d2-e3b8-5103-b74f-be209608a3cf","attributes":{"name":"invalid_session_forced_logout","description":"Force + reload on current_user 403 response / invalid session. Checked every minute.","value_type":"bool","value":false,"modified_at":null}},{"type":"org_configs","id":"d4a6259b-5599-5120-8bdb-22718cb09118","attributes":{"name":"custom_roles","description":"Enables + the custom roles (RBAC) UI.","value_type":"bool","value":false,"modified_at":null}},{"type":"org_configs","id":"61d24356-1d0a-51b2-ac77-16bddb9a4fbc","attributes":{"name":"log_anomaly_detection","description":"Whether + the API should return results for Logs Anomaly detection","value_type":"bool","value":true,"modified_at":null}},{"type":"org_configs","id":"4fcf5523-7578-5ebb-bf7f-cc0b96047ea5","attributes":{"name":"logs_has_set_flex_log_compute","description":"Org + config used to know an org has set flex log compute. This is useful to sync + the log query UI and preferred query storage type with flex log enablement.","value_type":"bool","value":false,"modified_at":null}},{"type":"org_configs","id":"1e20f9a8-ef08-5716-a466-d650854c9c62","attributes":{"name":"open_retentions","description":"Enables + users to set out of contract retentions.","value_type":"bool","value":false,"modified_at":null}},{"type":"org_configs","id":"87eeb191-0e80-575d-9b1f-2efed8aae16d","attributes":{"name":"admin_only_invites","description":"Restrict + user invites to only admins","value_type":"bool","value":false,"modified_at":null}},{"type":"org_configs","id":"47d07447-cee4-5f45-820a-3595c8c1ce21","attributes":{"name":"security_contacts","description":"List + of emails for security event notifications of an organization","value_type":"security_contacts_list","value":[],"modified_at":"2024-05-06T13:51:46.470206+00:00"}},{"type":"org_configs","id":"ba76efd8-79f3-52ee-8742-856c18e754c7","attributes":{"name":"teams_manage_membership","description":"Controls + who can manage membership for teams","value_type":"enum","value":"organization","modified_at":null}},{"type":"org_configs","id":"63be605e-4cc3-566b-94d8-475ab5137e25","attributes":{"name":"teams_edit_details","description":"Controls + who can edit team details","value_type":"enum","value":"members","modified_at":null}},{"type":"org_configs","id":"855e9fc7-449d-5fbf-9607-9f9bfca3dddf","attributes":{"name":"teams_provisioning_sources","description":"Determines + how users can be added to teams","value_type":"enum","value":"manually","modified_at":null}},{"type":"org_configs","id":"54efd4ec-bb21-5e8a-9cb8-712e18f8b6b7","attributes":{"name":"monitor_timezone","description":"Sets + the time zone used for monitoring alerts","value_type":"enum","value":"UTC","modified_at":null}}]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..5d6bd0c7870 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2024-06-12T14:43:54.474Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..ff5b62fa4ef --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Bad_Request_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"value":"not-a-boolean"},"type":"org_configs"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/org_configs/custom_roles + response: + body: '{"errors":["The value provided for parameter ''OrgConfig: not-a-boolean'' + is invalid"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..8c54ec652a8 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2024-06-12T14:43:54.951Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..4425856de10 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_Not_Found_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"value":[]},"type":"org_configs"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/org_configs/i_dont_exist + response: + body: '{"errors":["OrgConfig: i_dont_exist not found"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_OK_response.freeze new file mode 100644 index 00000000000..3f77206fc16 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-06-12T14:43:55.410Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_OK_response.yaml new file mode 100644 index 00000000000..ae5543ceb48 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Organizations/Scenario_Update_a_specific_Org_Config_returns_OK_response.yaml @@ -0,0 +1,25 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"value":"UTC"},"type":"org_configs"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/org_configs/monitor_timezone + response: + body: '{"data":{"type":"org_configs","id":"54efd4ec-bb21-5e8a-9cb8-712e18f8b6b7","attributes":{"name":"monitor_timezone","description":"Sets + the time zone used for monitoring alerts","value_type":"enum","value":"UTC","modified_at":"2024-06-12T14:43:55.693935+00:00"}}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v2/organizations.feature b/tests/scenarios/features/v2/organizations.feature index 57045426fd9..ddec7484e76 100644 --- a/tests/scenarios/features/v2/organizations.feature +++ b/tests/scenarios/features/v2/organizations.feature @@ -7,21 +7,80 @@ Feature: Organizations Given a valid "apiKeyAuth" key in the system And a valid "appKeyAuth" key in the system And an instance of "Organizations" API - And new "UploadIdPMetadata" request + + @generated @skip @team:DataDog/team-aaa-identity + Scenario: Get a specific Org Config value returns "Bad Request" response + Given new "GetOrgConfig" request + And request contains "org_config_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/team-aaa-identity + Scenario: Get a specific Org Config value returns "Not Found" response + Given new "GetOrgConfig" request + And request contains "org_config_name" parameter with value "i_dont_exist" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/team-aaa-identity + Scenario: Get a specific Org Config value returns "OK" response + Given new "GetOrgConfig" request + And request contains "org_config_name" parameter with value "custom_roles" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/team-aaa-identity + Scenario: List Org Configs returns "Bad Request" response + Given new "ListOrgConfigs" request + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/team-aaa-identity + Scenario: List Org Configs returns "OK" response + Given new "ListOrgConfigs" request + When the request is sent + Then the response status is 200 OK + + @team:DataDog/team-aaa-identity + Scenario: Update a specific Org Config returns "Bad Request" response + Given new "UpdateOrgConfig" request + And request contains "org_config_name" parameter with value "custom_roles" + And body with value {"data": {"attributes": {"value": "not-a-boolean"}, "type": "org_configs"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/team-aaa-identity + Scenario: Update a specific Org Config returns "Not Found" response + Given new "UpdateOrgConfig" request + And request contains "org_config_name" parameter with value "i_dont_exist" + And body with value {"data": {"attributes": {"value": []}, "type": "org_configs"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/team-aaa-identity + Scenario: Update a specific Org Config returns "OK" response + Given new "UpdateOrgConfig" request + And request contains "org_config_name" parameter with value "monitor_timezone" + And body with value {"data": {"attributes": {"value": "UTC"}, "type": "org_configs"}} + When the request is sent + Then the response status is 200 OK @skip-go @skip-java @skip-python @skip-ruby @skip-rust @skip-terraform-config @skip-typescript @skip-validation @team:DataDog/team-aaa-identity Scenario: Upload IdP metadata returns "Bad Request - caused by either malformed XML or invalid SAML IdP metadata" response - Given request contains "idp_file" parameter with value "fixtures/organizations/saml_configurations/invalid_idp_metadata.xml" + Given new "UploadIdPMetadata" request + And request contains "idp_file" parameter with value "fixtures/organizations/saml_configurations/invalid_idp_metadata.xml" When the request is sent Then the response status is 400 Bad Request - caused by either malformed XML or invalid SAML IdP metadata @generated @skip @team:DataDog/team-aaa-identity Scenario: Upload IdP metadata returns "Bad Request" response + Given new "UploadIdPMetadata" request When the request is sent Then the response status is 400 Bad Request @integration-only @skip-terraform-config @skip-validation @team:DataDog/team-aaa-identity Scenario: Upload IdP metadata returns "OK" response - Given request contains "idp_file" parameter with value "fixtures/organizations/saml_configurations/valid_idp_metadata.xml" + Given new "UploadIdPMetadata" request + And request contains "idp_file" parameter with value "fixtures/organizations/saml_configurations/valid_idp_metadata.xml" When the request is sent Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 226eb145652..0126ff4b812 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1297,6 +1297,24 @@ "type": "safe" } }, + "ListOrgConfigs": { + "tag": "Organizations", + "undo": { + "type": "safe" + } + }, + "GetOrgConfig": { + "tag": "Organizations", + "undo": { + "type": "safe" + } + }, + "UpdateOrgConfig": { + "tag": "Organizations", + "undo": { + "type": "idempotent" + } + }, "ListPermissions": { "tag": "Roles", "undo": {