diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 90e1196820e..53a4ea6a1a5 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -75076,6 +75076,18 @@ components: required: - data type: object + OwnershipConfidenceLevel: + description: The ownership confidence level. + enum: + - high + - medium + - low + example: high + type: string + x-enum-varnames: + - HIGH + - MEDIUM + - LOW OwnershipEvidenceAttributes: description: The attributes of an ownership evidence response. properties: @@ -75639,6 +75651,152 @@ components: - TEAM - SERVICE - UNKNOWN + OwnershipSettingsAttributes: + description: The attributes of the ownership settings response. + properties: + auto_tag: + description: Whether automatic ownership tagging is enabled. + example: true + type: boolean + confidence_level: + $ref: "#/components/schemas/OwnershipConfidenceLevel" + version: + description: The current version of the ownership settings. + example: 1 + format: int64 + type: integer + required: + - version + - auto_tag + - confidence_level + type: object + OwnershipSettingsData: + description: The data wrapper for an ownership settings response. + properties: + attributes: + $ref: "#/components/schemas/OwnershipSettingsAttributes" + id: + description: The identifier of the ownership settings resource. + example: settings + type: string + type: + $ref: "#/components/schemas/OwnershipSettingsType" + required: + - id + - type + - attributes + type: object + OwnershipSettingsRequest: + description: The request body for updating ownership settings. + properties: + data: + $ref: "#/components/schemas/OwnershipSettingsRequestData" + required: + - data + type: object + OwnershipSettingsRequestAttributes: + description: The attributes of an ownership settings request. + properties: + auto_tag: + description: Whether automatic ownership tagging is enabled. + example: true + type: boolean + confidence_level: + $ref: "#/components/schemas/OwnershipConfidenceLevel" + required: + - auto_tag + - confidence_level + type: object + OwnershipSettingsRequestData: + description: The data wrapper for an ownership settings request. + properties: + attributes: + $ref: "#/components/schemas/OwnershipSettingsRequestAttributes" + type: + $ref: "#/components/schemas/OwnershipSettingsType" + required: + - type + - attributes + type: object + OwnershipSettingsResponse: + description: The response returned when retrieving or updating ownership settings. + properties: + data: + $ref: "#/components/schemas/OwnershipSettingsData" + required: + - data + type: object + OwnershipSettingsType: + default: ownership_settings + description: The type of the ownership settings resource. The value should always be `ownership_settings`. + enum: + - ownership_settings + example: ownership_settings + type: string + x-enum-varnames: + - OWNERSHIP_SETTINGS + OwnershipUntaggedFindingsAttributes: + description: The counts of findings without a team tag by ownership confidence. + properties: + high_confidence: + description: The number of high confidence findings without a team tag. + example: 30 + format: int64 + type: integer + low_confidence: + description: The number of low confidence findings without a team tag. + example: 42 + format: int64 + type: integer + medium_confidence: + description: The number of medium confidence findings without a team tag. + example: 70 + format: int64 + type: integer + total: + description: The total number of findings without a team tag. + example: 142 + format: int64 + type: integer + required: + - total + - high_confidence + - medium_confidence + - low_confidence + type: object + OwnershipUntaggedFindingsData: + description: The data wrapper for an ownership untagged findings response. + properties: + attributes: + $ref: "#/components/schemas/OwnershipUntaggedFindingsAttributes" + id: + description: The identifier of the ownership untagged findings resource. + example: untagged + type: string + type: + $ref: "#/components/schemas/OwnershipUntaggedFindingsType" + required: + - id + - type + - attributes + type: object + OwnershipUntaggedFindingsResponse: + description: The response returned when counting findings without a team tag by ownership confidence. + properties: + data: + $ref: "#/components/schemas/OwnershipUntaggedFindingsData" + required: + - data + type: object + OwnershipUntaggedFindingsType: + default: ownership_untagged_findings + description: The type of the ownership untagged findings resource. The value should always be `ownership_untagged_findings`. + enum: + - ownership_untagged_findings + example: ownership_untagged_findings + type: string + x-enum-varnames: + - OWNERSHIP_UNTAGGED_FINDINGS PageAnnotationsAttributes: description: Attributes of the annotations on a page. properties: @@ -132295,6 +132453,128 @@ paths: $ref: "#/components/responses/TooManyRequestsResponse" summary: Get all CSM Serverless Agents tags: ["CSM Agents"] + /api/v2/csm/ownership/settings: + get: + description: Get ownership settings for the org. When settings are unset, the API returns the default opt-out configuration with `auto_tag` set to `true` and `confidence_level` set to `high`. + operationId: GetOwnershipSettings + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + auto_tag: true + confidence_level: high + version: 1 + id: settings + type: ownership_settings + schema: + $ref: "#/components/schemas/OwnershipSettingsResponse" + description: OK + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get ownership settings for the org + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + post: + description: Update ownership settings for the org. + operationId: PostOwnershipSettings + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + auto_tag: true + confidence_level: high + type: ownership_settings + schema: + $ref: "#/components/schemas/OwnershipSettingsRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + auto_tag: true + confidence_level: high + version: 1 + id: settings + type: ownership_settings + schema: + $ref: "#/components/schemas/OwnershipSettingsResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Update ownership settings for the org + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/csm/ownership/settings/untagged: + get: + description: Count findings with no team tag, grouped by ownership confidence level. + operationId: GetOwnershipUntaggedFindings + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + high_confidence: 30 + low_confidence: 42 + medium_confidence: 70 + total: 142 + id: untagged + type: ownership_untagged_findings + schema: + $ref: "#/components/schemas/OwnershipUntaggedFindingsResponse" + description: OK + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Count untagged findings by ownership confidence + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/csm/ownership/{resource_id}: get: description: Get all current ownership inferences for a resource, one per owner type (`user`, `team`, `service`, `unknown`). diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index a154edbb9d6..9fb4fda860f 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -878,9 +878,12 @@ func NewConfiguration() *Configuration { "v2.CreateOwnershipFeedback": false, "v2.GetOwnershipEvidence": false, "v2.GetOwnershipInference": false, + "v2.GetOwnershipSettings": false, + "v2.GetOwnershipUntaggedFindings": false, "v2.ListOwnershipHistory": false, "v2.ListOwnershipHistoryByOwnerType": false, "v2.ListOwnershipInferences": false, + "v2.PostOwnershipSettings": false, "v2.GetCSMAgentlessHostFacetInfo": false, "v2.GetCSMUnifiedHostFacetInfo": false, "v2.ListCSMAgentlessHostFacets": false, diff --git a/api/datadogV2/api_csm_ownership.go b/api/datadogV2/api_csm_ownership.go index b2aa1b7703f..c2843fd28b2 100644 --- a/api/datadogV2/api_csm_ownership.go +++ b/api/datadogV2/api_csm_ownership.go @@ -384,6 +384,196 @@ func (a *CSMOwnershipApi) GetOwnershipInference(ctx _context.Context, resourceId return localVarReturnValue, localVarHTTPResponse, nil } +// GetOwnershipSettings Get ownership settings for the org. +// Get ownership settings for the org. When settings are unset, the API returns the default opt-out configuration with `auto_tag` set to `true` and `confidence_level` set to `high`. +func (a *CSMOwnershipApi) GetOwnershipSettings(ctx _context.Context) (OwnershipSettingsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue OwnershipSettingsResponse + ) + + operationId := "v2.GetOwnershipSettings" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CSMOwnershipApi.GetOwnershipSettings") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/csm/ownership/settings" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 401 { + var v JSONAPIErrorResponse + 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 + } + if 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 +} + +// GetOwnershipUntaggedFindings Count untagged findings by ownership confidence. +// Count findings with no team tag, grouped by ownership confidence level. +func (a *CSMOwnershipApi) GetOwnershipUntaggedFindings(ctx _context.Context) (OwnershipUntaggedFindingsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue OwnershipUntaggedFindingsResponse + ) + + operationId := "v2.GetOwnershipUntaggedFindings" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CSMOwnershipApi.GetOwnershipUntaggedFindings") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/csm/ownership/settings/untagged" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 401 { + var v JSONAPIErrorResponse + 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 + } + if 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 +} + // ListOwnershipHistoryOptionalParameters holds optional parameters for ListOwnershipHistory. type ListOwnershipHistoryOptionalParameters struct { Cursor *string @@ -749,6 +939,104 @@ func (a *CSMOwnershipApi) ListOwnershipInferences(ctx _context.Context, resource return localVarReturnValue, localVarHTTPResponse, nil } +// PostOwnershipSettings Update ownership settings for the org. +// Update ownership settings for the org. +func (a *CSMOwnershipApi) PostOwnershipSettings(ctx _context.Context, body OwnershipSettingsRequest) (OwnershipSettingsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue OwnershipSettingsResponse + ) + + operationId := "v2.PostOwnershipSettings" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CSMOwnershipApi.PostOwnershipSettings") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/csm/ownership/settings" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 { + var v JSONAPIErrorResponse + 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 + } + if 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 +} + // NewCSMOwnershipApi Returns NewCSMOwnershipApi. func NewCSMOwnershipApi(client *datadog.APIClient) *CSMOwnershipApi { return &CSMOwnershipApi{ diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 0edea112337..75ee96ab80d 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -141,9 +141,12 @@ // - [CSMOwnershipApi.CreateOwnershipFeedback] // - [CSMOwnershipApi.GetOwnershipEvidence] // - [CSMOwnershipApi.GetOwnershipInference] +// - [CSMOwnershipApi.GetOwnershipSettings] +// - [CSMOwnershipApi.GetOwnershipUntaggedFindings] // - [CSMOwnershipApi.ListOwnershipHistory] // - [CSMOwnershipApi.ListOwnershipHistoryByOwnerType] // - [CSMOwnershipApi.ListOwnershipInferences] +// - [CSMOwnershipApi.PostOwnershipSettings] // - [CSMSettingsApi.GetCSMAgentlessHostFacetInfo] // - [CSMSettingsApi.GetCSMUnifiedHostFacetInfo] // - [CSMSettingsApi.ListCSMAgentlessHostFacets] diff --git a/api/datadogV2/model_ownership_confidence_level.go b/api/datadogV2/model_ownership_confidence_level.go new file mode 100644 index 00000000000..2b1ae2f7a93 --- /dev/null +++ b/api/datadogV2/model_ownership_confidence_level.go @@ -0,0 +1,68 @@ +// 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" +) + +// OwnershipConfidenceLevel The ownership confidence level. +type OwnershipConfidenceLevel string + +// List of OwnershipConfidenceLevel. +const ( + OWNERSHIPCONFIDENCELEVEL_HIGH OwnershipConfidenceLevel = "high" + OWNERSHIPCONFIDENCELEVEL_MEDIUM OwnershipConfidenceLevel = "medium" + OWNERSHIPCONFIDENCELEVEL_LOW OwnershipConfidenceLevel = "low" +) + +var allowedOwnershipConfidenceLevelEnumValues = []OwnershipConfidenceLevel{ + OWNERSHIPCONFIDENCELEVEL_HIGH, + OWNERSHIPCONFIDENCELEVEL_MEDIUM, + OWNERSHIPCONFIDENCELEVEL_LOW, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *OwnershipConfidenceLevel) GetAllowedValues() []OwnershipConfidenceLevel { + return allowedOwnershipConfidenceLevelEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *OwnershipConfidenceLevel) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = OwnershipConfidenceLevel(value) + return nil +} + +// NewOwnershipConfidenceLevelFromValue returns a pointer to a valid OwnershipConfidenceLevel +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewOwnershipConfidenceLevelFromValue(v string) (*OwnershipConfidenceLevel, error) { + ev := OwnershipConfidenceLevel(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for OwnershipConfidenceLevel: valid values are %v", v, allowedOwnershipConfidenceLevelEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v OwnershipConfidenceLevel) IsValid() bool { + for _, existing := range allowedOwnershipConfidenceLevelEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to OwnershipConfidenceLevel value. +func (v OwnershipConfidenceLevel) Ptr() *OwnershipConfidenceLevel { + return &v +} diff --git a/api/datadogV2/model_ownership_settings_attributes.go b/api/datadogV2/model_ownership_settings_attributes.go new file mode 100644 index 00000000000..a9e789a8173 --- /dev/null +++ b/api/datadogV2/model_ownership_settings_attributes.go @@ -0,0 +1,175 @@ +// 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" +) + +// OwnershipSettingsAttributes The attributes of the ownership settings response. +type OwnershipSettingsAttributes struct { + // Whether automatic ownership tagging is enabled. + AutoTag bool `json:"auto_tag"` + // The ownership confidence level. + ConfidenceLevel OwnershipConfidenceLevel `json:"confidence_level"` + // The current version of the ownership settings. + Version int64 `json:"version"` + // 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{} `json:"-"` +} + +// NewOwnershipSettingsAttributes instantiates a new OwnershipSettingsAttributes 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 NewOwnershipSettingsAttributes(autoTag bool, confidenceLevel OwnershipConfidenceLevel, version int64) *OwnershipSettingsAttributes { + this := OwnershipSettingsAttributes{} + this.AutoTag = autoTag + this.ConfidenceLevel = confidenceLevel + this.Version = version + return &this +} + +// NewOwnershipSettingsAttributesWithDefaults instantiates a new OwnershipSettingsAttributes 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 NewOwnershipSettingsAttributesWithDefaults() *OwnershipSettingsAttributes { + this := OwnershipSettingsAttributes{} + return &this +} + +// GetAutoTag returns the AutoTag field value. +func (o *OwnershipSettingsAttributes) GetAutoTag() bool { + if o == nil { + var ret bool + return ret + } + return o.AutoTag +} + +// GetAutoTagOk returns a tuple with the AutoTag field value +// and a boolean to check if the value has been set. +func (o *OwnershipSettingsAttributes) GetAutoTagOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.AutoTag, true +} + +// SetAutoTag sets field value. +func (o *OwnershipSettingsAttributes) SetAutoTag(v bool) { + o.AutoTag = v +} + +// GetConfidenceLevel returns the ConfidenceLevel field value. +func (o *OwnershipSettingsAttributes) GetConfidenceLevel() OwnershipConfidenceLevel { + if o == nil { + var ret OwnershipConfidenceLevel + return ret + } + return o.ConfidenceLevel +} + +// GetConfidenceLevelOk returns a tuple with the ConfidenceLevel field value +// and a boolean to check if the value has been set. +func (o *OwnershipSettingsAttributes) GetConfidenceLevelOk() (*OwnershipConfidenceLevel, bool) { + if o == nil { + return nil, false + } + return &o.ConfidenceLevel, true +} + +// SetConfidenceLevel sets field value. +func (o *OwnershipSettingsAttributes) SetConfidenceLevel(v OwnershipConfidenceLevel) { + o.ConfidenceLevel = v +} + +// GetVersion returns the Version field value. +func (o *OwnershipSettingsAttributes) GetVersion() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Version +} + +// GetVersionOk returns a tuple with the Version field value +// and a boolean to check if the value has been set. +func (o *OwnershipSettingsAttributes) GetVersionOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Version, true +} + +// SetVersion sets field value. +func (o *OwnershipSettingsAttributes) SetVersion(v int64) { + o.Version = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OwnershipSettingsAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["auto_tag"] = o.AutoTag + toSerialize["confidence_level"] = o.ConfidenceLevel + toSerialize["version"] = o.Version + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OwnershipSettingsAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AutoTag *bool `json:"auto_tag"` + ConfidenceLevel *OwnershipConfidenceLevel `json:"confidence_level"` + Version *int64 `json:"version"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AutoTag == nil { + return fmt.Errorf("required field auto_tag missing") + } + if all.ConfidenceLevel == nil { + return fmt.Errorf("required field confidence_level missing") + } + if all.Version == nil { + return fmt.Errorf("required field version missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"auto_tag", "confidence_level", "version"}) + } else { + return err + } + + hasInvalidField := false + o.AutoTag = *all.AutoTag + if !all.ConfidenceLevel.IsValid() { + hasInvalidField = true + } else { + o.ConfidenceLevel = *all.ConfidenceLevel + } + o.Version = *all.Version + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_ownership_settings_data.go b/api/datadogV2/model_ownership_settings_data.go new file mode 100644 index 00000000000..d53f0986c43 --- /dev/null +++ b/api/datadogV2/model_ownership_settings_data.go @@ -0,0 +1,180 @@ +// 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" +) + +// OwnershipSettingsData The data wrapper for an ownership settings response. +type OwnershipSettingsData struct { + // The attributes of the ownership settings response. + Attributes OwnershipSettingsAttributes `json:"attributes"` + // The identifier of the ownership settings resource. + Id string `json:"id"` + // The type of the ownership settings resource. The value should always be `ownership_settings`. + Type OwnershipSettingsType `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{} `json:"-"` +} + +// NewOwnershipSettingsData instantiates a new OwnershipSettingsData 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 NewOwnershipSettingsData(attributes OwnershipSettingsAttributes, id string, typeVar OwnershipSettingsType) *OwnershipSettingsData { + this := OwnershipSettingsData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewOwnershipSettingsDataWithDefaults instantiates a new OwnershipSettingsData 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 NewOwnershipSettingsDataWithDefaults() *OwnershipSettingsData { + this := OwnershipSettingsData{} + var typeVar OwnershipSettingsType = OWNERSHIPSETTINGSTYPE_OWNERSHIP_SETTINGS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *OwnershipSettingsData) GetAttributes() OwnershipSettingsAttributes { + if o == nil { + var ret OwnershipSettingsAttributes + 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 *OwnershipSettingsData) GetAttributesOk() (*OwnershipSettingsAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *OwnershipSettingsData) SetAttributes(v OwnershipSettingsAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *OwnershipSettingsData) 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 *OwnershipSettingsData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *OwnershipSettingsData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *OwnershipSettingsData) GetType() OwnershipSettingsType { + if o == nil { + var ret OwnershipSettingsType + 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 *OwnershipSettingsData) GetTypeOk() (*OwnershipSettingsType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *OwnershipSettingsData) SetType(v OwnershipSettingsType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OwnershipSettingsData) 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 *OwnershipSettingsData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *OwnershipSettingsAttributes `json:"attributes"` + Id *string `json:"id"` + Type *OwnershipSettingsType `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.UnmarshalUseNumber(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_ownership_settings_request.go b/api/datadogV2/model_ownership_settings_request.go new file mode 100644 index 00000000000..03094121b4a --- /dev/null +++ b/api/datadogV2/model_ownership_settings_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" +) + +// OwnershipSettingsRequest The request body for updating ownership settings. +type OwnershipSettingsRequest struct { + // The data wrapper for an ownership settings request. + Data OwnershipSettingsRequestData `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{} `json:"-"` +} + +// NewOwnershipSettingsRequest instantiates a new OwnershipSettingsRequest 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 NewOwnershipSettingsRequest(data OwnershipSettingsRequestData) *OwnershipSettingsRequest { + this := OwnershipSettingsRequest{} + this.Data = data + return &this +} + +// NewOwnershipSettingsRequestWithDefaults instantiates a new OwnershipSettingsRequest 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 NewOwnershipSettingsRequestWithDefaults() *OwnershipSettingsRequest { + this := OwnershipSettingsRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *OwnershipSettingsRequest) GetData() OwnershipSettingsRequestData { + if o == nil { + var ret OwnershipSettingsRequestData + 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 *OwnershipSettingsRequest) GetDataOk() (*OwnershipSettingsRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *OwnershipSettingsRequest) SetData(v OwnershipSettingsRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OwnershipSettingsRequest) 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 *OwnershipSettingsRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *OwnershipSettingsRequestData `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.UnmarshalUseNumber(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_ownership_settings_request_attributes.go b/api/datadogV2/model_ownership_settings_request_attributes.go new file mode 100644 index 00000000000..4f698223db8 --- /dev/null +++ b/api/datadogV2/model_ownership_settings_request_attributes.go @@ -0,0 +1,143 @@ +// 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" +) + +// OwnershipSettingsRequestAttributes The attributes of an ownership settings request. +type OwnershipSettingsRequestAttributes struct { + // Whether automatic ownership tagging is enabled. + AutoTag bool `json:"auto_tag"` + // The ownership confidence level. + ConfidenceLevel OwnershipConfidenceLevel `json:"confidence_level"` + // 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{} `json:"-"` +} + +// NewOwnershipSettingsRequestAttributes instantiates a new OwnershipSettingsRequestAttributes 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 NewOwnershipSettingsRequestAttributes(autoTag bool, confidenceLevel OwnershipConfidenceLevel) *OwnershipSettingsRequestAttributes { + this := OwnershipSettingsRequestAttributes{} + this.AutoTag = autoTag + this.ConfidenceLevel = confidenceLevel + return &this +} + +// NewOwnershipSettingsRequestAttributesWithDefaults instantiates a new OwnershipSettingsRequestAttributes 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 NewOwnershipSettingsRequestAttributesWithDefaults() *OwnershipSettingsRequestAttributes { + this := OwnershipSettingsRequestAttributes{} + return &this +} + +// GetAutoTag returns the AutoTag field value. +func (o *OwnershipSettingsRequestAttributes) GetAutoTag() bool { + if o == nil { + var ret bool + return ret + } + return o.AutoTag +} + +// GetAutoTagOk returns a tuple with the AutoTag field value +// and a boolean to check if the value has been set. +func (o *OwnershipSettingsRequestAttributes) GetAutoTagOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.AutoTag, true +} + +// SetAutoTag sets field value. +func (o *OwnershipSettingsRequestAttributes) SetAutoTag(v bool) { + o.AutoTag = v +} + +// GetConfidenceLevel returns the ConfidenceLevel field value. +func (o *OwnershipSettingsRequestAttributes) GetConfidenceLevel() OwnershipConfidenceLevel { + if o == nil { + var ret OwnershipConfidenceLevel + return ret + } + return o.ConfidenceLevel +} + +// GetConfidenceLevelOk returns a tuple with the ConfidenceLevel field value +// and a boolean to check if the value has been set. +func (o *OwnershipSettingsRequestAttributes) GetConfidenceLevelOk() (*OwnershipConfidenceLevel, bool) { + if o == nil { + return nil, false + } + return &o.ConfidenceLevel, true +} + +// SetConfidenceLevel sets field value. +func (o *OwnershipSettingsRequestAttributes) SetConfidenceLevel(v OwnershipConfidenceLevel) { + o.ConfidenceLevel = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OwnershipSettingsRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["auto_tag"] = o.AutoTag + toSerialize["confidence_level"] = o.ConfidenceLevel + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OwnershipSettingsRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AutoTag *bool `json:"auto_tag"` + ConfidenceLevel *OwnershipConfidenceLevel `json:"confidence_level"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AutoTag == nil { + return fmt.Errorf("required field auto_tag missing") + } + if all.ConfidenceLevel == nil { + return fmt.Errorf("required field confidence_level missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"auto_tag", "confidence_level"}) + } else { + return err + } + + hasInvalidField := false + o.AutoTag = *all.AutoTag + if !all.ConfidenceLevel.IsValid() { + hasInvalidField = true + } else { + o.ConfidenceLevel = *all.ConfidenceLevel + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_ownership_settings_request_data.go b/api/datadogV2/model_ownership_settings_request_data.go new file mode 100644 index 00000000000..9fc8db72695 --- /dev/null +++ b/api/datadogV2/model_ownership_settings_request_data.go @@ -0,0 +1,148 @@ +// 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" +) + +// OwnershipSettingsRequestData The data wrapper for an ownership settings request. +type OwnershipSettingsRequestData struct { + // The attributes of an ownership settings request. + Attributes OwnershipSettingsRequestAttributes `json:"attributes"` + // The type of the ownership settings resource. The value should always be `ownership_settings`. + Type OwnershipSettingsType `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{} `json:"-"` +} + +// NewOwnershipSettingsRequestData instantiates a new OwnershipSettingsRequestData 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 NewOwnershipSettingsRequestData(attributes OwnershipSettingsRequestAttributes, typeVar OwnershipSettingsType) *OwnershipSettingsRequestData { + this := OwnershipSettingsRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewOwnershipSettingsRequestDataWithDefaults instantiates a new OwnershipSettingsRequestData 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 NewOwnershipSettingsRequestDataWithDefaults() *OwnershipSettingsRequestData { + this := OwnershipSettingsRequestData{} + var typeVar OwnershipSettingsType = OWNERSHIPSETTINGSTYPE_OWNERSHIP_SETTINGS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *OwnershipSettingsRequestData) GetAttributes() OwnershipSettingsRequestAttributes { + if o == nil { + var ret OwnershipSettingsRequestAttributes + 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 *OwnershipSettingsRequestData) GetAttributesOk() (*OwnershipSettingsRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *OwnershipSettingsRequestData) SetAttributes(v OwnershipSettingsRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *OwnershipSettingsRequestData) GetType() OwnershipSettingsType { + if o == nil { + var ret OwnershipSettingsType + 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 *OwnershipSettingsRequestData) GetTypeOk() (*OwnershipSettingsType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *OwnershipSettingsRequestData) SetType(v OwnershipSettingsType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OwnershipSettingsRequestData) 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 *OwnershipSettingsRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *OwnershipSettingsRequestAttributes `json:"attributes"` + Type *OwnershipSettingsType `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.UnmarshalUseNumber(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_ownership_settings_response.go b/api/datadogV2/model_ownership_settings_response.go new file mode 100644 index 00000000000..04284ea7811 --- /dev/null +++ b/api/datadogV2/model_ownership_settings_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" +) + +// OwnershipSettingsResponse The response returned when retrieving or updating ownership settings. +type OwnershipSettingsResponse struct { + // The data wrapper for an ownership settings response. + Data OwnershipSettingsData `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{} `json:"-"` +} + +// NewOwnershipSettingsResponse instantiates a new OwnershipSettingsResponse 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 NewOwnershipSettingsResponse(data OwnershipSettingsData) *OwnershipSettingsResponse { + this := OwnershipSettingsResponse{} + this.Data = data + return &this +} + +// NewOwnershipSettingsResponseWithDefaults instantiates a new OwnershipSettingsResponse 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 NewOwnershipSettingsResponseWithDefaults() *OwnershipSettingsResponse { + this := OwnershipSettingsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *OwnershipSettingsResponse) GetData() OwnershipSettingsData { + if o == nil { + var ret OwnershipSettingsData + 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 *OwnershipSettingsResponse) GetDataOk() (*OwnershipSettingsData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *OwnershipSettingsResponse) SetData(v OwnershipSettingsData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OwnershipSettingsResponse) 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 *OwnershipSettingsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *OwnershipSettingsData `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.UnmarshalUseNumber(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_ownership_settings_type.go b/api/datadogV2/model_ownership_settings_type.go new file mode 100644 index 00000000000..c2e992fb85a --- /dev/null +++ b/api/datadogV2/model_ownership_settings_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" +) + +// OwnershipSettingsType The type of the ownership settings resource. The value should always be `ownership_settings`. +type OwnershipSettingsType string + +// List of OwnershipSettingsType. +const ( + OWNERSHIPSETTINGSTYPE_OWNERSHIP_SETTINGS OwnershipSettingsType = "ownership_settings" +) + +var allowedOwnershipSettingsTypeEnumValues = []OwnershipSettingsType{ + OWNERSHIPSETTINGSTYPE_OWNERSHIP_SETTINGS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *OwnershipSettingsType) GetAllowedValues() []OwnershipSettingsType { + return allowedOwnershipSettingsTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *OwnershipSettingsType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = OwnershipSettingsType(value) + return nil +} + +// NewOwnershipSettingsTypeFromValue returns a pointer to a valid OwnershipSettingsType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewOwnershipSettingsTypeFromValue(v string) (*OwnershipSettingsType, error) { + ev := OwnershipSettingsType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for OwnershipSettingsType: valid values are %v", v, allowedOwnershipSettingsTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v OwnershipSettingsType) IsValid() bool { + for _, existing := range allowedOwnershipSettingsTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to OwnershipSettingsType value. +func (v OwnershipSettingsType) Ptr() *OwnershipSettingsType { + return &v +} diff --git a/api/datadogV2/model_ownership_untagged_findings_attributes.go b/api/datadogV2/model_ownership_untagged_findings_attributes.go new file mode 100644 index 00000000000..92ed67da803 --- /dev/null +++ b/api/datadogV2/model_ownership_untagged_findings_attributes.go @@ -0,0 +1,197 @@ +// 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" +) + +// OwnershipUntaggedFindingsAttributes The counts of findings without a team tag by ownership confidence. +type OwnershipUntaggedFindingsAttributes struct { + // The number of high confidence findings without a team tag. + HighConfidence int64 `json:"high_confidence"` + // The number of low confidence findings without a team tag. + LowConfidence int64 `json:"low_confidence"` + // The number of medium confidence findings without a team tag. + MediumConfidence int64 `json:"medium_confidence"` + // The total number of findings without a team tag. + Total int64 `json:"total"` + // 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{} `json:"-"` +} + +// NewOwnershipUntaggedFindingsAttributes instantiates a new OwnershipUntaggedFindingsAttributes 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 NewOwnershipUntaggedFindingsAttributes(highConfidence int64, lowConfidence int64, mediumConfidence int64, total int64) *OwnershipUntaggedFindingsAttributes { + this := OwnershipUntaggedFindingsAttributes{} + this.HighConfidence = highConfidence + this.LowConfidence = lowConfidence + this.MediumConfidence = mediumConfidence + this.Total = total + return &this +} + +// NewOwnershipUntaggedFindingsAttributesWithDefaults instantiates a new OwnershipUntaggedFindingsAttributes 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 NewOwnershipUntaggedFindingsAttributesWithDefaults() *OwnershipUntaggedFindingsAttributes { + this := OwnershipUntaggedFindingsAttributes{} + return &this +} + +// GetHighConfidence returns the HighConfidence field value. +func (o *OwnershipUntaggedFindingsAttributes) GetHighConfidence() int64 { + if o == nil { + var ret int64 + return ret + } + return o.HighConfidence +} + +// GetHighConfidenceOk returns a tuple with the HighConfidence field value +// and a boolean to check if the value has been set. +func (o *OwnershipUntaggedFindingsAttributes) GetHighConfidenceOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.HighConfidence, true +} + +// SetHighConfidence sets field value. +func (o *OwnershipUntaggedFindingsAttributes) SetHighConfidence(v int64) { + o.HighConfidence = v +} + +// GetLowConfidence returns the LowConfidence field value. +func (o *OwnershipUntaggedFindingsAttributes) GetLowConfidence() int64 { + if o == nil { + var ret int64 + return ret + } + return o.LowConfidence +} + +// GetLowConfidenceOk returns a tuple with the LowConfidence field value +// and a boolean to check if the value has been set. +func (o *OwnershipUntaggedFindingsAttributes) GetLowConfidenceOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.LowConfidence, true +} + +// SetLowConfidence sets field value. +func (o *OwnershipUntaggedFindingsAttributes) SetLowConfidence(v int64) { + o.LowConfidence = v +} + +// GetMediumConfidence returns the MediumConfidence field value. +func (o *OwnershipUntaggedFindingsAttributes) GetMediumConfidence() int64 { + if o == nil { + var ret int64 + return ret + } + return o.MediumConfidence +} + +// GetMediumConfidenceOk returns a tuple with the MediumConfidence field value +// and a boolean to check if the value has been set. +func (o *OwnershipUntaggedFindingsAttributes) GetMediumConfidenceOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.MediumConfidence, true +} + +// SetMediumConfidence sets field value. +func (o *OwnershipUntaggedFindingsAttributes) SetMediumConfidence(v int64) { + o.MediumConfidence = v +} + +// GetTotal returns the Total field value. +func (o *OwnershipUntaggedFindingsAttributes) GetTotal() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Total +} + +// GetTotalOk returns a tuple with the Total field value +// and a boolean to check if the value has been set. +func (o *OwnershipUntaggedFindingsAttributes) GetTotalOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Total, true +} + +// SetTotal sets field value. +func (o *OwnershipUntaggedFindingsAttributes) SetTotal(v int64) { + o.Total = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OwnershipUntaggedFindingsAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["high_confidence"] = o.HighConfidence + toSerialize["low_confidence"] = o.LowConfidence + toSerialize["medium_confidence"] = o.MediumConfidence + toSerialize["total"] = o.Total + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OwnershipUntaggedFindingsAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + HighConfidence *int64 `json:"high_confidence"` + LowConfidence *int64 `json:"low_confidence"` + MediumConfidence *int64 `json:"medium_confidence"` + Total *int64 `json:"total"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.HighConfidence == nil { + return fmt.Errorf("required field high_confidence missing") + } + if all.LowConfidence == nil { + return fmt.Errorf("required field low_confidence missing") + } + if all.MediumConfidence == nil { + return fmt.Errorf("required field medium_confidence missing") + } + if all.Total == nil { + return fmt.Errorf("required field total missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"high_confidence", "low_confidence", "medium_confidence", "total"}) + } else { + return err + } + o.HighConfidence = *all.HighConfidence + o.LowConfidence = *all.LowConfidence + o.MediumConfidence = *all.MediumConfidence + o.Total = *all.Total + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_ownership_untagged_findings_data.go b/api/datadogV2/model_ownership_untagged_findings_data.go new file mode 100644 index 00000000000..d93fd94b516 --- /dev/null +++ b/api/datadogV2/model_ownership_untagged_findings_data.go @@ -0,0 +1,180 @@ +// 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" +) + +// OwnershipUntaggedFindingsData The data wrapper for an ownership untagged findings response. +type OwnershipUntaggedFindingsData struct { + // The counts of findings without a team tag by ownership confidence. + Attributes OwnershipUntaggedFindingsAttributes `json:"attributes"` + // The identifier of the ownership untagged findings resource. + Id string `json:"id"` + // The type of the ownership untagged findings resource. The value should always be `ownership_untagged_findings`. + Type OwnershipUntaggedFindingsType `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{} `json:"-"` +} + +// NewOwnershipUntaggedFindingsData instantiates a new OwnershipUntaggedFindingsData 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 NewOwnershipUntaggedFindingsData(attributes OwnershipUntaggedFindingsAttributes, id string, typeVar OwnershipUntaggedFindingsType) *OwnershipUntaggedFindingsData { + this := OwnershipUntaggedFindingsData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewOwnershipUntaggedFindingsDataWithDefaults instantiates a new OwnershipUntaggedFindingsData 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 NewOwnershipUntaggedFindingsDataWithDefaults() *OwnershipUntaggedFindingsData { + this := OwnershipUntaggedFindingsData{} + var typeVar OwnershipUntaggedFindingsType = OWNERSHIPUNTAGGEDFINDINGSTYPE_OWNERSHIP_UNTAGGED_FINDINGS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *OwnershipUntaggedFindingsData) GetAttributes() OwnershipUntaggedFindingsAttributes { + if o == nil { + var ret OwnershipUntaggedFindingsAttributes + 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 *OwnershipUntaggedFindingsData) GetAttributesOk() (*OwnershipUntaggedFindingsAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *OwnershipUntaggedFindingsData) SetAttributes(v OwnershipUntaggedFindingsAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *OwnershipUntaggedFindingsData) 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 *OwnershipUntaggedFindingsData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *OwnershipUntaggedFindingsData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *OwnershipUntaggedFindingsData) GetType() OwnershipUntaggedFindingsType { + if o == nil { + var ret OwnershipUntaggedFindingsType + 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 *OwnershipUntaggedFindingsData) GetTypeOk() (*OwnershipUntaggedFindingsType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *OwnershipUntaggedFindingsData) SetType(v OwnershipUntaggedFindingsType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OwnershipUntaggedFindingsData) 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 *OwnershipUntaggedFindingsData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *OwnershipUntaggedFindingsAttributes `json:"attributes"` + Id *string `json:"id"` + Type *OwnershipUntaggedFindingsType `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.UnmarshalUseNumber(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_ownership_untagged_findings_response.go b/api/datadogV2/model_ownership_untagged_findings_response.go new file mode 100644 index 00000000000..08fb23c4a32 --- /dev/null +++ b/api/datadogV2/model_ownership_untagged_findings_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" +) + +// OwnershipUntaggedFindingsResponse The response returned when counting findings without a team tag by ownership confidence. +type OwnershipUntaggedFindingsResponse struct { + // The data wrapper for an ownership untagged findings response. + Data OwnershipUntaggedFindingsData `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{} `json:"-"` +} + +// NewOwnershipUntaggedFindingsResponse instantiates a new OwnershipUntaggedFindingsResponse 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 NewOwnershipUntaggedFindingsResponse(data OwnershipUntaggedFindingsData) *OwnershipUntaggedFindingsResponse { + this := OwnershipUntaggedFindingsResponse{} + this.Data = data + return &this +} + +// NewOwnershipUntaggedFindingsResponseWithDefaults instantiates a new OwnershipUntaggedFindingsResponse 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 NewOwnershipUntaggedFindingsResponseWithDefaults() *OwnershipUntaggedFindingsResponse { + this := OwnershipUntaggedFindingsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *OwnershipUntaggedFindingsResponse) GetData() OwnershipUntaggedFindingsData { + if o == nil { + var ret OwnershipUntaggedFindingsData + 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 *OwnershipUntaggedFindingsResponse) GetDataOk() (*OwnershipUntaggedFindingsData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *OwnershipUntaggedFindingsResponse) SetData(v OwnershipUntaggedFindingsData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OwnershipUntaggedFindingsResponse) 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 *OwnershipUntaggedFindingsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *OwnershipUntaggedFindingsData `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.UnmarshalUseNumber(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_ownership_untagged_findings_type.go b/api/datadogV2/model_ownership_untagged_findings_type.go new file mode 100644 index 00000000000..bd5981fdb66 --- /dev/null +++ b/api/datadogV2/model_ownership_untagged_findings_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" +) + +// OwnershipUntaggedFindingsType The type of the ownership untagged findings resource. The value should always be `ownership_untagged_findings`. +type OwnershipUntaggedFindingsType string + +// List of OwnershipUntaggedFindingsType. +const ( + OWNERSHIPUNTAGGEDFINDINGSTYPE_OWNERSHIP_UNTAGGED_FINDINGS OwnershipUntaggedFindingsType = "ownership_untagged_findings" +) + +var allowedOwnershipUntaggedFindingsTypeEnumValues = []OwnershipUntaggedFindingsType{ + OWNERSHIPUNTAGGEDFINDINGSTYPE_OWNERSHIP_UNTAGGED_FINDINGS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *OwnershipUntaggedFindingsType) GetAllowedValues() []OwnershipUntaggedFindingsType { + return allowedOwnershipUntaggedFindingsTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *OwnershipUntaggedFindingsType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = OwnershipUntaggedFindingsType(value) + return nil +} + +// NewOwnershipUntaggedFindingsTypeFromValue returns a pointer to a valid OwnershipUntaggedFindingsType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewOwnershipUntaggedFindingsTypeFromValue(v string) (*OwnershipUntaggedFindingsType, error) { + ev := OwnershipUntaggedFindingsType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for OwnershipUntaggedFindingsType: valid values are %v", v, allowedOwnershipUntaggedFindingsTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v OwnershipUntaggedFindingsType) IsValid() bool { + for _, existing := range allowedOwnershipUntaggedFindingsTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to OwnershipUntaggedFindingsType value. +func (v OwnershipUntaggedFindingsType) Ptr() *OwnershipUntaggedFindingsType { + return &v +} diff --git a/examples/v2/csm-ownership/GetOwnershipSettings.go b/examples/v2/csm-ownership/GetOwnershipSettings.go new file mode 100644 index 00000000000..1f11cee9a99 --- /dev/null +++ b/examples/v2/csm-ownership/GetOwnershipSettings.go @@ -0,0 +1,30 @@ +// Get ownership settings for the org 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() + configuration.SetUnstableOperationEnabled("v2.GetOwnershipSettings", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCSMOwnershipApi(apiClient) + resp, r, err := api.GetOwnershipSettings(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CSMOwnershipApi.GetOwnershipSettings`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `CSMOwnershipApi.GetOwnershipSettings`:\n%s\n", responseContent) +} diff --git a/examples/v2/csm-ownership/GetOwnershipUntaggedFindings.go b/examples/v2/csm-ownership/GetOwnershipUntaggedFindings.go new file mode 100644 index 00000000000..aa9c71630e6 --- /dev/null +++ b/examples/v2/csm-ownership/GetOwnershipUntaggedFindings.go @@ -0,0 +1,30 @@ +// Count untagged findings by ownership confidence 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() + configuration.SetUnstableOperationEnabled("v2.GetOwnershipUntaggedFindings", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCSMOwnershipApi(apiClient) + resp, r, err := api.GetOwnershipUntaggedFindings(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CSMOwnershipApi.GetOwnershipUntaggedFindings`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `CSMOwnershipApi.GetOwnershipUntaggedFindings`:\n%s\n", responseContent) +} diff --git a/examples/v2/csm-ownership/PostOwnershipSettings.go b/examples/v2/csm-ownership/PostOwnershipSettings.go new file mode 100644 index 00000000000..36c4339de09 --- /dev/null +++ b/examples/v2/csm-ownership/PostOwnershipSettings.go @@ -0,0 +1,39 @@ +// Update ownership settings for the org 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.OwnershipSettingsRequest{ + Data: datadogV2.OwnershipSettingsRequestData{ + Attributes: datadogV2.OwnershipSettingsRequestAttributes{ + AutoTag: true, + ConfidenceLevel: datadogV2.OWNERSHIPCONFIDENCELEVEL_HIGH, + }, + Type: datadogV2.OWNERSHIPSETTINGSTYPE_OWNERSHIP_SETTINGS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.PostOwnershipSettings", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCSMOwnershipApi(apiClient) + resp, r, err := api.PostOwnershipSettings(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CSMOwnershipApi.PostOwnershipSettings`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `CSMOwnershipApi.PostOwnershipSettings`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/csm_ownership.feature b/tests/scenarios/features/v2/csm_ownership.feature index 58498ca1550..661e420b5c2 100644 --- a/tests/scenarios/features/v2/csm_ownership.feature +++ b/tests/scenarios/features/v2/csm_ownership.feature @@ -12,6 +12,13 @@ Feature: CSM Ownership And a valid "appKeyAuth" key in the system And an instance of "CSMOwnership" API + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Count untagged findings by ownership confidence returns "OK" response + Given operation "GetOwnershipUntaggedFindings" enabled + And new "GetOwnershipUntaggedFindings" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-misconfigs Scenario: Get an ownership inference by owner type returns "Bad Request" response Given operation "GetOwnershipInference" enabled @@ -39,6 +46,13 @@ Feature: CSM Ownership When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Get ownership settings for the org returns "OK" response + Given operation "GetOwnershipSettings" enabled + And new "GetOwnershipSettings" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-misconfigs Scenario: Get the evidence for an ownership inference returns "Bad Request" response Given operation "GetOwnershipEvidence" enabled @@ -163,3 +177,19 @@ Feature: CSM Ownership And body with value {"data": {"attributes": {"action": "confirm", "actor_handle": "user@example.com", "actor_type": "user", "corrected_owner_handle": "team-b", "corrected_owner_type": "team", "inference_checksum": "abc123", "reason": "Confirmed by team lead."}, "type": "ownership_feedback"}} When the request is sent Then the response status is 404 Not Found + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Update ownership settings for the org returns "Bad Request" response + Given operation "PostOwnershipSettings" enabled + And new "PostOwnershipSettings" request + And body with value {"data": {"attributes": {"auto_tag": true, "confidence_level": "high"}, "type": "ownership_settings"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Update ownership settings for the org returns "OK" response + Given operation "PostOwnershipSettings" enabled + And new "PostOwnershipSettings" request + And body with value {"data": {"attributes": {"auto_tag": true, "confidence_level": "high"}, "type": "ownership_settings"}} + 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 e72767d8e0d..10ae8ac71d4 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2049,6 +2049,24 @@ "type": "safe" } }, + "GetOwnershipSettings": { + "tag": "CSM Ownership", + "undo": { + "type": "safe" + } + }, + "PostOwnershipSettings": { + "tag": "CSM Ownership", + "undo": { + "type": "idempotent" + } + }, + "GetOwnershipUntaggedFindings": { + "tag": "CSM Ownership", + "undo": { + "type": "safe" + } + }, "ListOwnershipInferences": { "tag": "CSM Ownership", "undo": {