diff --git a/.apigentools-info b/.apigentools-info index f599638c1f3..664c1cec7c2 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-07 22:36:04.659059", - "spec_repo_commit": "8233abfb" + "regenerated": "2024-11-08 14:25:40.171557", + "spec_repo_commit": "d907813e" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-07 22:36:04.678214", - "spec_repo_commit": "8233abfb" + "regenerated": "2024-11-08 14:25:40.189971", + "spec_repo_commit": "d907813e" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ce1fe2fc60d..a3a38ebca93 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -293,6 +293,13 @@ components: required: true schema: type: string + HistoricalJobID: + description: The ID of the job. + in: path + name: job_id + required: true + schema: + type: string IncidentAttachmentFilterQueryParameter: description: Specifies which types of attachments are included in the response. explode: false @@ -3658,6 +3665,21 @@ components: from the other indexes type: string type: object + CalculatedField: + description: Calculated field. + properties: + expression: + description: Expression. + example: '@request_end_timestamp - @request_start_timestamp' + type: string + name: + description: Field name. + example: response_time + type: string + required: + - name + - expression + type: object Case: description: A case properties: @@ -5540,6 +5562,59 @@ components: - IDENTITY - GZIP - DEFLATE + ConvertJobResultsToSignalsAttributes: + description: Attributes for converting historical job results to signals. + properties: + id: + description: Request ID. + type: string + jobResultIds: + description: Job result IDs. + example: + - '' + items: + type: string + type: array + notifications: + description: Notifications sent. + example: + - '' + items: + type: string + type: array + signalMessage: + description: Message of generated signals. + example: A large number of failed login attempts. + type: string + signalSeverity: + $ref: '#/components/schemas/SecurityMonitoringRuleSeverity' + required: + - jobResultIds + - signalSeverity + - signalMessage + - notifications + type: object + ConvertJobResultsToSignalsData: + description: Data for converting historical job results to signals. + properties: + attributes: + $ref: '#/components/schemas/ConvertJobResultsToSignalsAttributes' + type: + $ref: '#/components/schemas/ConvertJobResultsToSignalsDataType' + type: object + ConvertJobResultsToSignalsDataType: + description: Type of payload. + enum: + - historicalDetectionsJobResultSignalConversion + type: string + x-enum-varnames: + - HISTORICALDETECTIONSJOBRESULTSIGNALCONVERSION + ConvertJobResultsToSignalsRequest: + description: Request for converting historical job results to signals. + properties: + data: + $ref: '#/components/schemas/ConvertJobResultsToSignalsData' + type: object CostAttributionAggregates: description: An array of available aggregates. items: @@ -10112,6 +10187,67 @@ components: required: - message type: object + HistoricalJobDataType: + description: Type of payload. + enum: + - historicalDetectionsJob + type: string + x-enum-varnames: + - HISTORICALDETECTIONSJOB + HistoricalJobListMeta: + description: Metadata about the list of jobs. + properties: + totalCount: + description: Number of jobs in the list. + format: int32 + maximum: 2147483647 + type: integer + type: object + HistoricalJobResponse: + description: Historical job response. + properties: + data: + $ref: '#/components/schemas/HistoricalJobResponseData' + type: object + HistoricalJobResponseAttributes: + description: Historical job attributes. + properties: + createdAt: + description: Time when the job was created. + type: string + createdByHandle: + description: The handle of the user who created the job. + type: string + createdByName: + description: The name of the user who created the job. + type: string + createdFromRuleId: + description: ID of the rule used to create the job (if it is created from + a rule). + type: string + jobDefinition: + $ref: '#/components/schemas/JobDefinition' + jobName: + description: Job name. + type: string + jobStatus: + description: Job status. + type: string + modifiedAt: + description: Last modification time of the job. + type: string + type: object + HistoricalJobResponseData: + description: Historical job response data. + properties: + attributes: + $ref: '#/components/schemas/HistoricalJobResponseAttributes' + id: + description: ID of the job. + type: string + type: + $ref: '#/components/schemas/HistoricalJobDataType' + type: object HourlyUsage: description: Hourly usage for a product family for an org. properties: @@ -12542,6 +12678,140 @@ components: description: Jira project key type: string type: object + JobCreateResponse: + description: Run a historical job response. + properties: + data: + $ref: '#/components/schemas/JobCreateResponseData' + type: object + JobCreateResponseData: + description: The definition of `JobCreateResponseData` object. + properties: + id: + description: ID of the created job. + type: string + type: + $ref: '#/components/schemas/HistoricalJobDataType' + type: object + JobDefinition: + description: Definition of a historical job. + properties: + calculatedFields: + description: Calculated fields. + items: + $ref: '#/components/schemas/CalculatedField' + type: array + cases: + description: Cases used for generating job results. + items: + $ref: '#/components/schemas/SecurityMonitoringRuleCaseCreate' + type: array + filters: + description: Additional queries to filter matched events before they are + processed. This field is deprecated for log detection, signal correlation, + and workload security rules. + items: + $ref: '#/components/schemas/SecurityMonitoringFilter' + type: array + from: + description: Starting time of data analyzed by the job. + example: 1729843470000 + format: int64 + type: integer + index: + description: Index used to load the data. + example: cloud_siem + type: string + message: + description: Message for generated results. + example: A large number of failed login attempts. + type: string + name: + description: Job name. + example: Excessive number of failed attempts. + type: string + options: + $ref: '#/components/schemas/SecurityMonitoringRuleOptions' + queries: + description: Queries for selecting logs analyzed by the job. + items: + $ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery' + type: array + referenceTables: + description: Reference tables for the rule. + items: + $ref: '#/components/schemas/SecurityMonitoringReferenceTable' + type: array + tags: + description: Tags for generated signals. + items: + type: string + type: array + thirdPartyCases: + description: Cases for generating results from third-party rules. Only available + for third-party rules. + example: [] + items: + $ref: '#/components/schemas/SecurityMonitoringThirdPartyRuleCaseCreate' + type: array + to: + description: Ending time of data analyzed by the job. + example: 1729847070000 + format: int64 + type: integer + type: + description: Job type. + type: string + required: + - from + - to + - index + - name + - cases + - queries + - message + type: object + JobDefinitionFromRule: + description: Definition of a historical job based on a security monitoring rule. + properties: + caseIndex: + description: Index of the rule case applied by the job. + example: 0 + format: int32 + maximum: 9 + type: integer + from: + description: Starting time of data analyzed by the job. + example: 1729843470000 + format: int64 + type: integer + id: + description: ID of the detection rule used to create the job. + example: abc-def-ghi + type: string + index: + description: Index used to load the data. + example: cloud_siem + type: string + notifications: + description: Notifications sent when the job is completed. + example: + - '@sns-cloudtrail-results' + items: + type: string + type: array + to: + description: Ending time of data analyzed by the job. + example: 1729847070000 + format: int64 + type: integer + required: + - id + - from + - to + - index + - caseIndex + type: object LeakedKey: description: The definition of LeakedKey object. properties: @@ -12772,6 +13042,17 @@ components: - data - meta type: object + ListHistoricalJobsResponse: + description: List of historical jobs. + properties: + data: + description: Array containing the list of historical jobs. + items: + $ref: '#/components/schemas/HistoricalJobResponseData' + type: array + meta: + $ref: '#/components/schemas/HistoricalJobListMeta' + type: object ListPowerpacksResponse: description: Response object which includes all powerpack configurations. properties: @@ -19600,6 +19881,38 @@ components: $ref: '#/components/schemas/RumMetricResponseData' type: array type: object + RunHistoricalJobRequest: + description: Run a historical job request. + properties: + data: + $ref: '#/components/schemas/RunHistoricalJobRequestData' + type: object + RunHistoricalJobRequestAttributes: + description: Run a historical job request. + properties: + fromRule: + $ref: '#/components/schemas/JobDefinitionFromRule' + id: + description: Request ID. + type: string + jobDefinition: + $ref: '#/components/schemas/JobDefinition' + type: object + RunHistoricalJobRequestData: + description: Data for running a historical job request. + properties: + attributes: + $ref: '#/components/schemas/RunHistoricalJobRequestAttributes' + type: + $ref: '#/components/schemas/RunHistoricalJobRequestDataType' + type: object + RunHistoricalJobRequestDataType: + description: Type of data. + enum: + - historicalDetectionsJobCreate + type: string + x-enum-varnames: + - HISTORICALDETECTIONSJOBCREATE SAMLAssertionAttribute: description: SAML assertion attribute. properties: @@ -39611,6 +39924,213 @@ paths: permissions: - incident_settings_write x-unstable: '**Note**: This endpoint is deprecated.' + /api/v2/siem-historical-detections/jobs: + get: + description: List historical jobs. + operationId: ListHistoricalJobs + parameters: + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/PageNumber' + - description: The order of the jobs in results. + example: status + in: query + name: sort + required: false + schema: + type: string + - description: Query used to filter items from the fetched list. + example: security:attack status:high + in: query + name: filter[query] + required: false + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListHistoricalJobsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: List historical jobs + tags: + - Security Monitoring + x-unstable: '**Note**: This endpoint is in beta and may be subject to changes. + + Please check the documentation regularly for updates.' + post: + description: Run a historical job. + operationId: RunHistoricalJob + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RunHistoricalJobRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/JobCreateResponse' + description: Status created + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/ConcurrentModificationResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Run a historical job + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in beta and may be subject to changes. + + Please check the documentation regularly for updates.' + /api/v2/siem-historical-detections/jobs/signal_convert: + post: + description: Convert a job result to a signal. + operationId: ConvertJobResultToSignal + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ConvertJobResultsToSignalsRequest' + required: true + responses: + '204': + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/ConcurrentModificationResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Convert a job result to a signal + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in beta and may be subject to changes. + + Please check the documentation regularly for updates.' + /api/v2/siem-historical-detections/jobs/{job_id}: + delete: + description: Delete an existing job. + operationId: DeleteHistoricalJob + parameters: + - $ref: '#/components/parameters/HistoricalJobID' + responses: + '204': + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/ConcurrentModificationResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Delete an existing job + tags: + - Security Monitoring + x-unstable: '**Note**: This endpoint is in beta and may be subject to changes. + + Please check the documentation regularly for updates.' + get: + description: Get a job's details. + operationId: GetHistoricalJob + parameters: + - $ref: '#/components/parameters/HistoricalJobID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/HistoricalJobResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Get a job's details + tags: + - Security Monitoring + x-unstable: '**Note**: This endpoint is in beta and may be subject to changes. + + Please check the documentation regularly for updates.' + /api/v2/siem-historical-detections/jobs/{job_id}/cancel: + patch: + description: Cancel a historical job. + operationId: CancelHistoricalJob + parameters: + - $ref: '#/components/parameters/HistoricalJobID' + responses: + '204': + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/ConcurrentModificationResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Cancel a historical job + tags: + - Security Monitoring + x-unstable: '**Note**: This endpoint is in beta and may be subject to changes. + + Please check the documentation regularly for updates.' /api/v2/slo/report: post: description: 'Create a job to generate an SLO report. The report job is processed diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 2e00376c789..b2399949087 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -356,9 +356,15 @@ func NewConfiguration() *Configuration { "v2.UpdateIncidentIntegration": false, "v2.UpdateIncidentTodo": false, "v2.UpdateIncidentType": false, + "v2.CancelHistoricalJob": false, + "v2.ConvertJobResultToSignal": false, + "v2.DeleteHistoricalJob": false, "v2.GetFinding": false, + "v2.GetHistoricalJob": false, "v2.ListFindings": false, + "v2.ListHistoricalJobs": false, "v2.MuteFindings": false, + "v2.RunHistoricalJob": false, "v2.CreateScorecardOutcomesBatch": false, "v2.CreateScorecardRule": false, "v2.DeleteScorecardRule": false, diff --git a/api/datadogV2/api_security_monitoring.go b/api/datadogV2/api_security_monitoring.go index 5c8f01c0e40..dafcaf1528e 100644 --- a/api/datadogV2/api_security_monitoring.go +++ b/api/datadogV2/api_security_monitoring.go @@ -20,6 +20,74 @@ import ( // SecurityMonitoringApi service type type SecurityMonitoringApi datadog.Service +// CancelHistoricalJob Cancel a historical job. +// Cancel a historical job. +func (a *SecurityMonitoringApi) CancelHistoricalJob(ctx _context.Context, jobId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + ) + + operationId := "v2.CancelHistoricalJob" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.CancelHistoricalJob") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/siem-historical-detections/jobs/{job_id}/cancel" + localVarPath = strings.Replace(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return 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 == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // ConvertExistingSecurityMonitoringRule Convert an existing rule from JSON to Terraform. // Convert an existing rule from JSON to Terraform for datadog provider // resource datadog_security_monitoring_rule. @@ -92,6 +160,76 @@ func (a *SecurityMonitoringApi) ConvertExistingSecurityMonitoringRule(ctx _conte return localVarReturnValue, localVarHTTPResponse, nil } +// ConvertJobResultToSignal Convert a job result to a signal. +// Convert a job result to a signal. +func (a *SecurityMonitoringApi) ConvertJobResultToSignal(ctx _context.Context, body ConvertJobResultsToSignalsRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + ) + + operationId := "v2.ConvertJobResultToSignal" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.ConvertJobResultToSignal") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/siem-historical-detections/jobs/signal_convert" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + // 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return 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 localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // ConvertSecurityMonitoringRuleFromJSONToTerraform Convert a rule from JSON to Terraform. // Convert a rule that doesn't (yet) exist from JSON to Terraform for datadog provider // resource datadog_security_monitoring_rule. @@ -388,6 +526,74 @@ func (a *SecurityMonitoringApi) CreateSecurityMonitoringSuppression(ctx _context return localVarReturnValue, localVarHTTPResponse, nil } +// DeleteHistoricalJob Delete an existing job. +// Delete an existing job. +func (a *SecurityMonitoringApi) DeleteHistoricalJob(ctx _context.Context, jobId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.DeleteHistoricalJob" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.DeleteHistoricalJob") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/siem-historical-detections/jobs/{job_id}" + localVarPath = strings.Replace(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return 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 == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // DeleteSecurityFilter Delete a security filter. // Delete a specific security filter. func (a *SecurityMonitoringApi) DeleteSecurityFilter(ctx _context.Context, securityFilterId string) (*_nethttp.Response, error) { @@ -899,6 +1105,84 @@ func (a *SecurityMonitoringApi) GetFinding(ctx _context.Context, findingId strin return localVarReturnValue, localVarHTTPResponse, nil } +// GetHistoricalJob Get a job's details. +// Get a job's details. +func (a *SecurityMonitoringApi) GetHistoricalJob(ctx _context.Context, jobId string) (HistoricalJobResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue HistoricalJobResponse + ) + + operationId := "v2.GetHistoricalJob" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.GetHistoricalJob") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/siem-historical-detections/jobs/{job_id}" + localVarPath = strings.Replace(localVarPath, "{"+"job_id"+"}", _neturl.PathEscape(datadog.ParameterToString(jobId, "")), -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 == 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 +} + // GetSecurityFilter Get a security filter. // Get the details of a specific security filter. // @@ -1506,6 +1790,141 @@ func (a *SecurityMonitoringApi) ListFindingsWithPagination(ctx _context.Context, return items, cancel } +// ListHistoricalJobsOptionalParameters holds optional parameters for ListHistoricalJobs. +type ListHistoricalJobsOptionalParameters struct { + PageSize *int64 + PageNumber *int64 + Sort *string + FilterQuery *string +} + +// NewListHistoricalJobsOptionalParameters creates an empty struct for parameters. +func NewListHistoricalJobsOptionalParameters() *ListHistoricalJobsOptionalParameters { + this := ListHistoricalJobsOptionalParameters{} + return &this +} + +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *ListHistoricalJobsOptionalParameters) WithPageSize(pageSize int64) *ListHistoricalJobsOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageNumber sets the corresponding parameter name and returns the struct. +func (r *ListHistoricalJobsOptionalParameters) WithPageNumber(pageNumber int64) *ListHistoricalJobsOptionalParameters { + r.PageNumber = &pageNumber + return r +} + +// WithSort sets the corresponding parameter name and returns the struct. +func (r *ListHistoricalJobsOptionalParameters) WithSort(sort string) *ListHistoricalJobsOptionalParameters { + r.Sort = &sort + return r +} + +// WithFilterQuery sets the corresponding parameter name and returns the struct. +func (r *ListHistoricalJobsOptionalParameters) WithFilterQuery(filterQuery string) *ListHistoricalJobsOptionalParameters { + r.FilterQuery = &filterQuery + return r +} + +// ListHistoricalJobs List historical jobs. +// List historical jobs. +func (a *SecurityMonitoringApi) ListHistoricalJobs(ctx _context.Context, o ...ListHistoricalJobsOptionalParameters) (ListHistoricalJobsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ListHistoricalJobsResponse + optionalParams ListHistoricalJobsOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListHistoricalJobsOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ListHistoricalJobs" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.ListHistoricalJobs") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/siem-historical-detections/jobs" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.PageSize != nil { + localVarQueryParams.Add("page[size]", datadog.ParameterToString(*optionalParams.PageSize, "")) + } + if optionalParams.PageNumber != nil { + localVarQueryParams.Add("page[number]", datadog.ParameterToString(*optionalParams.PageNumber, "")) + } + if optionalParams.Sort != nil { + localVarQueryParams.Add("sort", datadog.ParameterToString(*optionalParams.Sort, "")) + } + if optionalParams.FilterQuery != nil { + localVarQueryParams.Add("filter[query]", datadog.ParameterToString(*optionalParams.FilterQuery, "")) + } + 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 == 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 +} + // ListSecurityFilters Get all security filters. // Get the list of configured security filters with their definitions. func (a *SecurityMonitoringApi) ListSecurityFilters(ctx _context.Context) (SecurityFiltersResponse, *_nethttp.Response, error) { @@ -2042,6 +2461,86 @@ func (a *SecurityMonitoringApi) MuteFindings(ctx _context.Context, body BulkMute return localVarReturnValue, localVarHTTPResponse, nil } +// RunHistoricalJob Run a historical job. +// Run a historical job. +func (a *SecurityMonitoringApi) RunHistoricalJob(ctx _context.Context, body RunHistoricalJobRequest) (JobCreateResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue JobCreateResponse + ) + + operationId := "v2.RunHistoricalJob" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.RunHistoricalJob") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/siem-historical-detections/jobs" + + 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 +} + // SearchSecurityMonitoringSignalsOptionalParameters holds optional parameters for SearchSecurityMonitoringSignals. type SearchSecurityMonitoringSignalsOptionalParameters struct { Body *SecurityMonitoringSignalListRequest diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 25a26eb6911..1880a055a76 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -268,11 +268,14 @@ // - [RumMetricsApi.GetRumMetric] // - [RumMetricsApi.ListRumMetrics] // - [RumMetricsApi.UpdateRumMetric] +// - [SecurityMonitoringApi.CancelHistoricalJob] // - [SecurityMonitoringApi.ConvertExistingSecurityMonitoringRule] +// - [SecurityMonitoringApi.ConvertJobResultToSignal] // - [SecurityMonitoringApi.ConvertSecurityMonitoringRuleFromJSONToTerraform] // - [SecurityMonitoringApi.CreateSecurityFilter] // - [SecurityMonitoringApi.CreateSecurityMonitoringRule] // - [SecurityMonitoringApi.CreateSecurityMonitoringSuppression] +// - [SecurityMonitoringApi.DeleteHistoricalJob] // - [SecurityMonitoringApi.DeleteSecurityFilter] // - [SecurityMonitoringApi.DeleteSecurityMonitoringRule] // - [SecurityMonitoringApi.DeleteSecurityMonitoringSuppression] @@ -280,16 +283,19 @@ // - [SecurityMonitoringApi.EditSecurityMonitoringSignalIncidents] // - [SecurityMonitoringApi.EditSecurityMonitoringSignalState] // - [SecurityMonitoringApi.GetFinding] +// - [SecurityMonitoringApi.GetHistoricalJob] // - [SecurityMonitoringApi.GetSecurityFilter] // - [SecurityMonitoringApi.GetSecurityMonitoringRule] // - [SecurityMonitoringApi.GetSecurityMonitoringSignal] // - [SecurityMonitoringApi.GetSecurityMonitoringSuppression] // - [SecurityMonitoringApi.ListFindings] +// - [SecurityMonitoringApi.ListHistoricalJobs] // - [SecurityMonitoringApi.ListSecurityFilters] // - [SecurityMonitoringApi.ListSecurityMonitoringRules] // - [SecurityMonitoringApi.ListSecurityMonitoringSignals] // - [SecurityMonitoringApi.ListSecurityMonitoringSuppressions] // - [SecurityMonitoringApi.MuteFindings] +// - [SecurityMonitoringApi.RunHistoricalJob] // - [SecurityMonitoringApi.SearchSecurityMonitoringSignals] // - [SecurityMonitoringApi.TestExistingSecurityMonitoringRule] // - [SecurityMonitoringApi.TestSecurityMonitoringRule] diff --git a/api/datadogV2/model_calculated_field.go b/api/datadogV2/model_calculated_field.go new file mode 100644 index 00000000000..6bd77bdf9b7 --- /dev/null +++ b/api/datadogV2/model_calculated_field.go @@ -0,0 +1,133 @@ +// 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" +) + +// CalculatedField Calculated field. +type CalculatedField struct { + // Expression. + Expression string `json:"expression"` + // Field name. + Name string `json:"name"` + // 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:"-"` +} + +// NewCalculatedField instantiates a new CalculatedField 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 NewCalculatedField(expression string, name string) *CalculatedField { + this := CalculatedField{} + this.Expression = expression + this.Name = name + return &this +} + +// NewCalculatedFieldWithDefaults instantiates a new CalculatedField 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 NewCalculatedFieldWithDefaults() *CalculatedField { + this := CalculatedField{} + return &this +} + +// GetExpression returns the Expression field value. +func (o *CalculatedField) GetExpression() string { + if o == nil { + var ret string + return ret + } + return o.Expression +} + +// GetExpressionOk returns a tuple with the Expression field value +// and a boolean to check if the value has been set. +func (o *CalculatedField) GetExpressionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Expression, true +} + +// SetExpression sets field value. +func (o *CalculatedField) SetExpression(v string) { + o.Expression = v +} + +// GetName returns the Name field value. +func (o *CalculatedField) 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 *CalculatedField) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *CalculatedField) SetName(v string) { + o.Name = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CalculatedField) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["expression"] = o.Expression + toSerialize["name"] = o.Name + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CalculatedField) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Expression *string `json:"expression"` + Name *string `json:"name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Expression == nil { + return fmt.Errorf("required field expression missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"expression", "name"}) + } else { + return err + } + o.Expression = *all.Expression + o.Name = *all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_convert_job_results_to_signals_attributes.go b/api/datadogV2/model_convert_job_results_to_signals_attributes.go new file mode 100644 index 00000000000..e10ac0e0ec0 --- /dev/null +++ b/api/datadogV2/model_convert_job_results_to_signals_attributes.go @@ -0,0 +1,242 @@ +// 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" +) + +// ConvertJobResultsToSignalsAttributes Attributes for converting historical job results to signals. +type ConvertJobResultsToSignalsAttributes struct { + // Request ID. + Id *string `json:"id,omitempty"` + // Job result IDs. + JobResultIds []string `json:"jobResultIds"` + // Notifications sent. + Notifications []string `json:"notifications"` + // Message of generated signals. + SignalMessage string `json:"signalMessage"` + // Severity of the Security Signal. + SignalSeverity SecurityMonitoringRuleSeverity `json:"signalSeverity"` + // 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:"-"` +} + +// NewConvertJobResultsToSignalsAttributes instantiates a new ConvertJobResultsToSignalsAttributes 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 NewConvertJobResultsToSignalsAttributes(jobResultIds []string, notifications []string, signalMessage string, signalSeverity SecurityMonitoringRuleSeverity) *ConvertJobResultsToSignalsAttributes { + this := ConvertJobResultsToSignalsAttributes{} + this.JobResultIds = jobResultIds + this.Notifications = notifications + this.SignalMessage = signalMessage + this.SignalSeverity = signalSeverity + return &this +} + +// NewConvertJobResultsToSignalsAttributesWithDefaults instantiates a new ConvertJobResultsToSignalsAttributes 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 NewConvertJobResultsToSignalsAttributesWithDefaults() *ConvertJobResultsToSignalsAttributes { + this := ConvertJobResultsToSignalsAttributes{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ConvertJobResultsToSignalsAttributes) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ConvertJobResultsToSignalsAttributes) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *ConvertJobResultsToSignalsAttributes) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *ConvertJobResultsToSignalsAttributes) SetId(v string) { + o.Id = &v +} + +// GetJobResultIds returns the JobResultIds field value. +func (o *ConvertJobResultsToSignalsAttributes) GetJobResultIds() []string { + if o == nil { + var ret []string + return ret + } + return o.JobResultIds +} + +// GetJobResultIdsOk returns a tuple with the JobResultIds field value +// and a boolean to check if the value has been set. +func (o *ConvertJobResultsToSignalsAttributes) GetJobResultIdsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.JobResultIds, true +} + +// SetJobResultIds sets field value. +func (o *ConvertJobResultsToSignalsAttributes) SetJobResultIds(v []string) { + o.JobResultIds = v +} + +// GetNotifications returns the Notifications field value. +func (o *ConvertJobResultsToSignalsAttributes) GetNotifications() []string { + if o == nil { + var ret []string + return ret + } + return o.Notifications +} + +// GetNotificationsOk returns a tuple with the Notifications field value +// and a boolean to check if the value has been set. +func (o *ConvertJobResultsToSignalsAttributes) GetNotificationsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Notifications, true +} + +// SetNotifications sets field value. +func (o *ConvertJobResultsToSignalsAttributes) SetNotifications(v []string) { + o.Notifications = v +} + +// GetSignalMessage returns the SignalMessage field value. +func (o *ConvertJobResultsToSignalsAttributes) GetSignalMessage() string { + if o == nil { + var ret string + return ret + } + return o.SignalMessage +} + +// GetSignalMessageOk returns a tuple with the SignalMessage field value +// and a boolean to check if the value has been set. +func (o *ConvertJobResultsToSignalsAttributes) GetSignalMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.SignalMessage, true +} + +// SetSignalMessage sets field value. +func (o *ConvertJobResultsToSignalsAttributes) SetSignalMessage(v string) { + o.SignalMessage = v +} + +// GetSignalSeverity returns the SignalSeverity field value. +func (o *ConvertJobResultsToSignalsAttributes) GetSignalSeverity() SecurityMonitoringRuleSeverity { + if o == nil { + var ret SecurityMonitoringRuleSeverity + return ret + } + return o.SignalSeverity +} + +// GetSignalSeverityOk returns a tuple with the SignalSeverity field value +// and a boolean to check if the value has been set. +func (o *ConvertJobResultsToSignalsAttributes) GetSignalSeverityOk() (*SecurityMonitoringRuleSeverity, bool) { + if o == nil { + return nil, false + } + return &o.SignalSeverity, true +} + +// SetSignalSeverity sets field value. +func (o *ConvertJobResultsToSignalsAttributes) SetSignalSeverity(v SecurityMonitoringRuleSeverity) { + o.SignalSeverity = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ConvertJobResultsToSignalsAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + toSerialize["jobResultIds"] = o.JobResultIds + toSerialize["notifications"] = o.Notifications + toSerialize["signalMessage"] = o.SignalMessage + toSerialize["signalSeverity"] = o.SignalSeverity + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ConvertJobResultsToSignalsAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + JobResultIds *[]string `json:"jobResultIds"` + Notifications *[]string `json:"notifications"` + SignalMessage *string `json:"signalMessage"` + SignalSeverity *SecurityMonitoringRuleSeverity `json:"signalSeverity"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.JobResultIds == nil { + return fmt.Errorf("required field jobResultIds missing") + } + if all.Notifications == nil { + return fmt.Errorf("required field notifications missing") + } + if all.SignalMessage == nil { + return fmt.Errorf("required field signalMessage missing") + } + if all.SignalSeverity == nil { + return fmt.Errorf("required field signalSeverity missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "jobResultIds", "notifications", "signalMessage", "signalSeverity"}) + } else { + return err + } + + hasInvalidField := false + o.Id = all.Id + o.JobResultIds = *all.JobResultIds + o.Notifications = *all.Notifications + o.SignalMessage = *all.SignalMessage + if !all.SignalSeverity.IsValid() { + hasInvalidField = true + } else { + o.SignalSeverity = *all.SignalSeverity + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_convert_job_results_to_signals_data.go b/api/datadogV2/model_convert_job_results_to_signals_data.go new file mode 100644 index 00000000000..a46b9ce101c --- /dev/null +++ b/api/datadogV2/model_convert_job_results_to_signals_data.go @@ -0,0 +1,150 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ConvertJobResultsToSignalsData Data for converting historical job results to signals. +type ConvertJobResultsToSignalsData struct { + // Attributes for converting historical job results to signals. + Attributes *ConvertJobResultsToSignalsAttributes `json:"attributes,omitempty"` + // Type of payload. + Type *ConvertJobResultsToSignalsDataType `json:"type,omitempty"` + // 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:"-"` +} + +// NewConvertJobResultsToSignalsData instantiates a new ConvertJobResultsToSignalsData 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 NewConvertJobResultsToSignalsData() *ConvertJobResultsToSignalsData { + this := ConvertJobResultsToSignalsData{} + return &this +} + +// NewConvertJobResultsToSignalsDataWithDefaults instantiates a new ConvertJobResultsToSignalsData 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 NewConvertJobResultsToSignalsDataWithDefaults() *ConvertJobResultsToSignalsData { + this := ConvertJobResultsToSignalsData{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *ConvertJobResultsToSignalsData) GetAttributes() ConvertJobResultsToSignalsAttributes { + if o == nil || o.Attributes == nil { + var ret ConvertJobResultsToSignalsAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ConvertJobResultsToSignalsData) GetAttributesOk() (*ConvertJobResultsToSignalsAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *ConvertJobResultsToSignalsData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given ConvertJobResultsToSignalsAttributes and assigns it to the Attributes field. +func (o *ConvertJobResultsToSignalsData) SetAttributes(v ConvertJobResultsToSignalsAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ConvertJobResultsToSignalsData) GetType() ConvertJobResultsToSignalsDataType { + if o == nil || o.Type == nil { + var ret ConvertJobResultsToSignalsDataType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ConvertJobResultsToSignalsData) GetTypeOk() (*ConvertJobResultsToSignalsDataType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ConvertJobResultsToSignalsData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ConvertJobResultsToSignalsDataType and assigns it to the Type field. +func (o *ConvertJobResultsToSignalsData) SetType(v ConvertJobResultsToSignalsDataType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ConvertJobResultsToSignalsData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ConvertJobResultsToSignalsData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ConvertJobResultsToSignalsAttributes `json:"attributes,omitempty"` + Type *ConvertJobResultsToSignalsDataType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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 != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if all.Type != nil && !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_convert_job_results_to_signals_data_type.go b/api/datadogV2/model_convert_job_results_to_signals_data_type.go new file mode 100644 index 00000000000..85356220442 --- /dev/null +++ b/api/datadogV2/model_convert_job_results_to_signals_data_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" +) + +// ConvertJobResultsToSignalsDataType Type of payload. +type ConvertJobResultsToSignalsDataType string + +// List of ConvertJobResultsToSignalsDataType. +const ( + CONVERTJOBRESULTSTOSIGNALSDATATYPE_HISTORICALDETECTIONSJOBRESULTSIGNALCONVERSION ConvertJobResultsToSignalsDataType = "historicalDetectionsJobResultSignalConversion" +) + +var allowedConvertJobResultsToSignalsDataTypeEnumValues = []ConvertJobResultsToSignalsDataType{ + CONVERTJOBRESULTSTOSIGNALSDATATYPE_HISTORICALDETECTIONSJOBRESULTSIGNALCONVERSION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ConvertJobResultsToSignalsDataType) GetAllowedValues() []ConvertJobResultsToSignalsDataType { + return allowedConvertJobResultsToSignalsDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ConvertJobResultsToSignalsDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ConvertJobResultsToSignalsDataType(value) + return nil +} + +// NewConvertJobResultsToSignalsDataTypeFromValue returns a pointer to a valid ConvertJobResultsToSignalsDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewConvertJobResultsToSignalsDataTypeFromValue(v string) (*ConvertJobResultsToSignalsDataType, error) { + ev := ConvertJobResultsToSignalsDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ConvertJobResultsToSignalsDataType: valid values are %v", v, allowedConvertJobResultsToSignalsDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ConvertJobResultsToSignalsDataType) IsValid() bool { + for _, existing := range allowedConvertJobResultsToSignalsDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ConvertJobResultsToSignalsDataType value. +func (v ConvertJobResultsToSignalsDataType) Ptr() *ConvertJobResultsToSignalsDataType { + return &v +} diff --git a/api/datadogV2/model_convert_job_results_to_signals_request.go b/api/datadogV2/model_convert_job_results_to_signals_request.go new file mode 100644 index 00000000000..5f4d94aabc6 --- /dev/null +++ b/api/datadogV2/model_convert_job_results_to_signals_request.go @@ -0,0 +1,111 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ConvertJobResultsToSignalsRequest Request for converting historical job results to signals. +type ConvertJobResultsToSignalsRequest struct { + // Data for converting historical job results to signals. + Data *ConvertJobResultsToSignalsData `json:"data,omitempty"` + // 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:"-"` +} + +// NewConvertJobResultsToSignalsRequest instantiates a new ConvertJobResultsToSignalsRequest 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 NewConvertJobResultsToSignalsRequest() *ConvertJobResultsToSignalsRequest { + this := ConvertJobResultsToSignalsRequest{} + return &this +} + +// NewConvertJobResultsToSignalsRequestWithDefaults instantiates a new ConvertJobResultsToSignalsRequest 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 NewConvertJobResultsToSignalsRequestWithDefaults() *ConvertJobResultsToSignalsRequest { + this := ConvertJobResultsToSignalsRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ConvertJobResultsToSignalsRequest) GetData() ConvertJobResultsToSignalsData { + if o == nil || o.Data == nil { + var ret ConvertJobResultsToSignalsData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ConvertJobResultsToSignalsRequest) GetDataOk() (*ConvertJobResultsToSignalsData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *ConvertJobResultsToSignalsRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given ConvertJobResultsToSignalsData and assigns it to the Data field. +func (o *ConvertJobResultsToSignalsRequest) SetData(v ConvertJobResultsToSignalsData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ConvertJobResultsToSignalsRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ConvertJobResultsToSignalsRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ConvertJobResultsToSignalsData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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 != nil && 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_historical_job_data_type.go b/api/datadogV2/model_historical_job_data_type.go new file mode 100644 index 00000000000..2982b37eedb --- /dev/null +++ b/api/datadogV2/model_historical_job_data_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" +) + +// HistoricalJobDataType Type of payload. +type HistoricalJobDataType string + +// List of HistoricalJobDataType. +const ( + HISTORICALJOBDATATYPE_HISTORICALDETECTIONSJOB HistoricalJobDataType = "historicalDetectionsJob" +) + +var allowedHistoricalJobDataTypeEnumValues = []HistoricalJobDataType{ + HISTORICALJOBDATATYPE_HISTORICALDETECTIONSJOB, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *HistoricalJobDataType) GetAllowedValues() []HistoricalJobDataType { + return allowedHistoricalJobDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *HistoricalJobDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = HistoricalJobDataType(value) + return nil +} + +// NewHistoricalJobDataTypeFromValue returns a pointer to a valid HistoricalJobDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewHistoricalJobDataTypeFromValue(v string) (*HistoricalJobDataType, error) { + ev := HistoricalJobDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for HistoricalJobDataType: valid values are %v", v, allowedHistoricalJobDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v HistoricalJobDataType) IsValid() bool { + for _, existing := range allowedHistoricalJobDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to HistoricalJobDataType value. +func (v HistoricalJobDataType) Ptr() *HistoricalJobDataType { + return &v +} diff --git a/api/datadogV2/model_historical_job_list_meta.go b/api/datadogV2/model_historical_job_list_meta.go new file mode 100644 index 00000000000..76174babdc5 --- /dev/null +++ b/api/datadogV2/model_historical_job_list_meta.go @@ -0,0 +1,102 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// HistoricalJobListMeta Metadata about the list of jobs. +type HistoricalJobListMeta struct { + // Number of jobs in the list. + TotalCount *int32 `json:"totalCount,omitempty"` + // 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:"-"` +} + +// NewHistoricalJobListMeta instantiates a new HistoricalJobListMeta 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 NewHistoricalJobListMeta() *HistoricalJobListMeta { + this := HistoricalJobListMeta{} + return &this +} + +// NewHistoricalJobListMetaWithDefaults instantiates a new HistoricalJobListMeta 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 NewHistoricalJobListMetaWithDefaults() *HistoricalJobListMeta { + this := HistoricalJobListMeta{} + return &this +} + +// GetTotalCount returns the TotalCount field value if set, zero value otherwise. +func (o *HistoricalJobListMeta) GetTotalCount() int32 { + if o == nil || o.TotalCount == nil { + var ret int32 + return ret + } + return *o.TotalCount +} + +// GetTotalCountOk returns a tuple with the TotalCount field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobListMeta) GetTotalCountOk() (*int32, bool) { + if o == nil || o.TotalCount == nil { + return nil, false + } + return o.TotalCount, true +} + +// HasTotalCount returns a boolean if a field has been set. +func (o *HistoricalJobListMeta) HasTotalCount() bool { + return o != nil && o.TotalCount != nil +} + +// SetTotalCount gets a reference to the given int32 and assigns it to the TotalCount field. +func (o *HistoricalJobListMeta) SetTotalCount(v int32) { + o.TotalCount = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HistoricalJobListMeta) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.TotalCount != nil { + toSerialize["totalCount"] = o.TotalCount + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HistoricalJobListMeta) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + TotalCount *int32 `json:"totalCount,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"totalCount"}) + } else { + return err + } + o.TotalCount = all.TotalCount + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_historical_job_response.go b/api/datadogV2/model_historical_job_response.go new file mode 100644 index 00000000000..c839d95d7d5 --- /dev/null +++ b/api/datadogV2/model_historical_job_response.go @@ -0,0 +1,111 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// HistoricalJobResponse Historical job response. +type HistoricalJobResponse struct { + // Historical job response data. + Data *HistoricalJobResponseData `json:"data,omitempty"` + // 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:"-"` +} + +// NewHistoricalJobResponse instantiates a new HistoricalJobResponse 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 NewHistoricalJobResponse() *HistoricalJobResponse { + this := HistoricalJobResponse{} + return &this +} + +// NewHistoricalJobResponseWithDefaults instantiates a new HistoricalJobResponse 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 NewHistoricalJobResponseWithDefaults() *HistoricalJobResponse { + this := HistoricalJobResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *HistoricalJobResponse) GetData() HistoricalJobResponseData { + if o == nil || o.Data == nil { + var ret HistoricalJobResponseData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponse) GetDataOk() (*HistoricalJobResponseData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *HistoricalJobResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given HistoricalJobResponseData and assigns it to the Data field. +func (o *HistoricalJobResponse) SetData(v HistoricalJobResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HistoricalJobResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HistoricalJobResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *HistoricalJobResponseData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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 != nil && 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_historical_job_response_attributes.go b/api/datadogV2/model_historical_job_response_attributes.go new file mode 100644 index 00000000000..5fa9130cc8d --- /dev/null +++ b/api/datadogV2/model_historical_job_response_attributes.go @@ -0,0 +1,356 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// HistoricalJobResponseAttributes Historical job attributes. +type HistoricalJobResponseAttributes struct { + // Time when the job was created. + CreatedAt *string `json:"createdAt,omitempty"` + // The handle of the user who created the job. + CreatedByHandle *string `json:"createdByHandle,omitempty"` + // The name of the user who created the job. + CreatedByName *string `json:"createdByName,omitempty"` + // ID of the rule used to create the job (if it is created from a rule). + CreatedFromRuleId *string `json:"createdFromRuleId,omitempty"` + // Definition of a historical job. + JobDefinition *JobDefinition `json:"jobDefinition,omitempty"` + // Job name. + JobName *string `json:"jobName,omitempty"` + // Job status. + JobStatus *string `json:"jobStatus,omitempty"` + // Last modification time of the job. + ModifiedAt *string `json:"modifiedAt,omitempty"` + // 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:"-"` +} + +// NewHistoricalJobResponseAttributes instantiates a new HistoricalJobResponseAttributes 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 NewHistoricalJobResponseAttributes() *HistoricalJobResponseAttributes { + this := HistoricalJobResponseAttributes{} + return &this +} + +// NewHistoricalJobResponseAttributesWithDefaults instantiates a new HistoricalJobResponseAttributes 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 NewHistoricalJobResponseAttributesWithDefaults() *HistoricalJobResponseAttributes { + this := HistoricalJobResponseAttributes{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *HistoricalJobResponseAttributes) GetCreatedAt() string { + if o == nil || o.CreatedAt == nil { + var ret string + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseAttributes) GetCreatedAtOk() (*string, bool) { + if o == nil || o.CreatedAt == nil { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *HistoricalJobResponseAttributes) HasCreatedAt() bool { + return o != nil && o.CreatedAt != nil +} + +// SetCreatedAt gets a reference to the given string and assigns it to the CreatedAt field. +func (o *HistoricalJobResponseAttributes) SetCreatedAt(v string) { + o.CreatedAt = &v +} + +// GetCreatedByHandle returns the CreatedByHandle field value if set, zero value otherwise. +func (o *HistoricalJobResponseAttributes) GetCreatedByHandle() string { + if o == nil || o.CreatedByHandle == nil { + var ret string + return ret + } + return *o.CreatedByHandle +} + +// GetCreatedByHandleOk returns a tuple with the CreatedByHandle field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseAttributes) GetCreatedByHandleOk() (*string, bool) { + if o == nil || o.CreatedByHandle == nil { + return nil, false + } + return o.CreatedByHandle, true +} + +// HasCreatedByHandle returns a boolean if a field has been set. +func (o *HistoricalJobResponseAttributes) HasCreatedByHandle() bool { + return o != nil && o.CreatedByHandle != nil +} + +// SetCreatedByHandle gets a reference to the given string and assigns it to the CreatedByHandle field. +func (o *HistoricalJobResponseAttributes) SetCreatedByHandle(v string) { + o.CreatedByHandle = &v +} + +// GetCreatedByName returns the CreatedByName field value if set, zero value otherwise. +func (o *HistoricalJobResponseAttributes) GetCreatedByName() string { + if o == nil || o.CreatedByName == nil { + var ret string + return ret + } + return *o.CreatedByName +} + +// GetCreatedByNameOk returns a tuple with the CreatedByName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseAttributes) GetCreatedByNameOk() (*string, bool) { + if o == nil || o.CreatedByName == nil { + return nil, false + } + return o.CreatedByName, true +} + +// HasCreatedByName returns a boolean if a field has been set. +func (o *HistoricalJobResponseAttributes) HasCreatedByName() bool { + return o != nil && o.CreatedByName != nil +} + +// SetCreatedByName gets a reference to the given string and assigns it to the CreatedByName field. +func (o *HistoricalJobResponseAttributes) SetCreatedByName(v string) { + o.CreatedByName = &v +} + +// GetCreatedFromRuleId returns the CreatedFromRuleId field value if set, zero value otherwise. +func (o *HistoricalJobResponseAttributes) GetCreatedFromRuleId() string { + if o == nil || o.CreatedFromRuleId == nil { + var ret string + return ret + } + return *o.CreatedFromRuleId +} + +// GetCreatedFromRuleIdOk returns a tuple with the CreatedFromRuleId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseAttributes) GetCreatedFromRuleIdOk() (*string, bool) { + if o == nil || o.CreatedFromRuleId == nil { + return nil, false + } + return o.CreatedFromRuleId, true +} + +// HasCreatedFromRuleId returns a boolean if a field has been set. +func (o *HistoricalJobResponseAttributes) HasCreatedFromRuleId() bool { + return o != nil && o.CreatedFromRuleId != nil +} + +// SetCreatedFromRuleId gets a reference to the given string and assigns it to the CreatedFromRuleId field. +func (o *HistoricalJobResponseAttributes) SetCreatedFromRuleId(v string) { + o.CreatedFromRuleId = &v +} + +// GetJobDefinition returns the JobDefinition field value if set, zero value otherwise. +func (o *HistoricalJobResponseAttributes) GetJobDefinition() JobDefinition { + if o == nil || o.JobDefinition == nil { + var ret JobDefinition + return ret + } + return *o.JobDefinition +} + +// GetJobDefinitionOk returns a tuple with the JobDefinition field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseAttributes) GetJobDefinitionOk() (*JobDefinition, bool) { + if o == nil || o.JobDefinition == nil { + return nil, false + } + return o.JobDefinition, true +} + +// HasJobDefinition returns a boolean if a field has been set. +func (o *HistoricalJobResponseAttributes) HasJobDefinition() bool { + return o != nil && o.JobDefinition != nil +} + +// SetJobDefinition gets a reference to the given JobDefinition and assigns it to the JobDefinition field. +func (o *HistoricalJobResponseAttributes) SetJobDefinition(v JobDefinition) { + o.JobDefinition = &v +} + +// GetJobName returns the JobName field value if set, zero value otherwise. +func (o *HistoricalJobResponseAttributes) GetJobName() string { + if o == nil || o.JobName == nil { + var ret string + return ret + } + return *o.JobName +} + +// GetJobNameOk returns a tuple with the JobName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseAttributes) GetJobNameOk() (*string, bool) { + if o == nil || o.JobName == nil { + return nil, false + } + return o.JobName, true +} + +// HasJobName returns a boolean if a field has been set. +func (o *HistoricalJobResponseAttributes) HasJobName() bool { + return o != nil && o.JobName != nil +} + +// SetJobName gets a reference to the given string and assigns it to the JobName field. +func (o *HistoricalJobResponseAttributes) SetJobName(v string) { + o.JobName = &v +} + +// GetJobStatus returns the JobStatus field value if set, zero value otherwise. +func (o *HistoricalJobResponseAttributes) GetJobStatus() string { + if o == nil || o.JobStatus == nil { + var ret string + return ret + } + return *o.JobStatus +} + +// GetJobStatusOk returns a tuple with the JobStatus field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseAttributes) GetJobStatusOk() (*string, bool) { + if o == nil || o.JobStatus == nil { + return nil, false + } + return o.JobStatus, true +} + +// HasJobStatus returns a boolean if a field has been set. +func (o *HistoricalJobResponseAttributes) HasJobStatus() bool { + return o != nil && o.JobStatus != nil +} + +// SetJobStatus gets a reference to the given string and assigns it to the JobStatus field. +func (o *HistoricalJobResponseAttributes) SetJobStatus(v string) { + o.JobStatus = &v +} + +// GetModifiedAt returns the ModifiedAt field value if set, zero value otherwise. +func (o *HistoricalJobResponseAttributes) GetModifiedAt() string { + if o == nil || o.ModifiedAt == nil { + var ret string + return ret + } + return *o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseAttributes) GetModifiedAtOk() (*string, bool) { + if o == nil || o.ModifiedAt == nil { + return nil, false + } + return o.ModifiedAt, true +} + +// HasModifiedAt returns a boolean if a field has been set. +func (o *HistoricalJobResponseAttributes) HasModifiedAt() bool { + return o != nil && o.ModifiedAt != nil +} + +// SetModifiedAt gets a reference to the given string and assigns it to the ModifiedAt field. +func (o *HistoricalJobResponseAttributes) SetModifiedAt(v string) { + o.ModifiedAt = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HistoricalJobResponseAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedAt != nil { + toSerialize["createdAt"] = o.CreatedAt + } + if o.CreatedByHandle != nil { + toSerialize["createdByHandle"] = o.CreatedByHandle + } + if o.CreatedByName != nil { + toSerialize["createdByName"] = o.CreatedByName + } + if o.CreatedFromRuleId != nil { + toSerialize["createdFromRuleId"] = o.CreatedFromRuleId + } + if o.JobDefinition != nil { + toSerialize["jobDefinition"] = o.JobDefinition + } + if o.JobName != nil { + toSerialize["jobName"] = o.JobName + } + if o.JobStatus != nil { + toSerialize["jobStatus"] = o.JobStatus + } + if o.ModifiedAt != nil { + toSerialize["modifiedAt"] = o.ModifiedAt + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HistoricalJobResponseAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedByHandle *string `json:"createdByHandle,omitempty"` + CreatedByName *string `json:"createdByName,omitempty"` + CreatedFromRuleId *string `json:"createdFromRuleId,omitempty"` + JobDefinition *JobDefinition `json:"jobDefinition,omitempty"` + JobName *string `json:"jobName,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + ModifiedAt *string `json:"modifiedAt,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"createdAt", "createdByHandle", "createdByName", "createdFromRuleId", "jobDefinition", "jobName", "jobStatus", "modifiedAt"}) + } else { + return err + } + + hasInvalidField := false + o.CreatedAt = all.CreatedAt + o.CreatedByHandle = all.CreatedByHandle + o.CreatedByName = all.CreatedByName + o.CreatedFromRuleId = all.CreatedFromRuleId + if all.JobDefinition != nil && all.JobDefinition.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.JobDefinition = all.JobDefinition + o.JobName = all.JobName + o.JobStatus = all.JobStatus + o.ModifiedAt = all.ModifiedAt + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_historical_job_response_data.go b/api/datadogV2/model_historical_job_response_data.go new file mode 100644 index 00000000000..984e256a9cd --- /dev/null +++ b/api/datadogV2/model_historical_job_response_data.go @@ -0,0 +1,185 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// HistoricalJobResponseData Historical job response data. +type HistoricalJobResponseData struct { + // Historical job attributes. + Attributes *HistoricalJobResponseAttributes `json:"attributes,omitempty"` + // ID of the job. + Id *string `json:"id,omitempty"` + // Type of payload. + Type *HistoricalJobDataType `json:"type,omitempty"` + // 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:"-"` +} + +// NewHistoricalJobResponseData instantiates a new HistoricalJobResponseData 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 NewHistoricalJobResponseData() *HistoricalJobResponseData { + this := HistoricalJobResponseData{} + return &this +} + +// NewHistoricalJobResponseDataWithDefaults instantiates a new HistoricalJobResponseData 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 NewHistoricalJobResponseDataWithDefaults() *HistoricalJobResponseData { + this := HistoricalJobResponseData{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *HistoricalJobResponseData) GetAttributes() HistoricalJobResponseAttributes { + if o == nil || o.Attributes == nil { + var ret HistoricalJobResponseAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseData) GetAttributesOk() (*HistoricalJobResponseAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *HistoricalJobResponseData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given HistoricalJobResponseAttributes and assigns it to the Attributes field. +func (o *HistoricalJobResponseData) SetAttributes(v HistoricalJobResponseAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *HistoricalJobResponseData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *HistoricalJobResponseData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *HistoricalJobResponseData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *HistoricalJobResponseData) GetType() HistoricalJobDataType { + if o == nil || o.Type == nil { + var ret HistoricalJobDataType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HistoricalJobResponseData) GetTypeOk() (*HistoricalJobDataType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *HistoricalJobResponseData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given HistoricalJobDataType and assigns it to the Type field. +func (o *HistoricalJobResponseData) SetType(v HistoricalJobDataType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o HistoricalJobResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *HistoricalJobResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *HistoricalJobResponseAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *HistoricalJobDataType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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 != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Type != nil && !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_job_create_response.go b/api/datadogV2/model_job_create_response.go new file mode 100644 index 00000000000..ab21b2563bf --- /dev/null +++ b/api/datadogV2/model_job_create_response.go @@ -0,0 +1,111 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JobCreateResponse Run a historical job response. +type JobCreateResponse struct { + // The definition of `JobCreateResponseData` object. + Data *JobCreateResponseData `json:"data,omitempty"` + // 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:"-"` +} + +// NewJobCreateResponse instantiates a new JobCreateResponse 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 NewJobCreateResponse() *JobCreateResponse { + this := JobCreateResponse{} + return &this +} + +// NewJobCreateResponseWithDefaults instantiates a new JobCreateResponse 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 NewJobCreateResponseWithDefaults() *JobCreateResponse { + this := JobCreateResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *JobCreateResponse) GetData() JobCreateResponseData { + if o == nil || o.Data == nil { + var ret JobCreateResponseData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobCreateResponse) GetDataOk() (*JobCreateResponseData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *JobCreateResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given JobCreateResponseData and assigns it to the Data field. +func (o *JobCreateResponse) SetData(v JobCreateResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JobCreateResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JobCreateResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *JobCreateResponseData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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 != nil && 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_job_create_response_data.go b/api/datadogV2/model_job_create_response_data.go new file mode 100644 index 00000000000..efa90b06214 --- /dev/null +++ b/api/datadogV2/model_job_create_response_data.go @@ -0,0 +1,147 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// JobCreateResponseData The definition of `JobCreateResponseData` object. +type JobCreateResponseData struct { + // ID of the created job. + Id *string `json:"id,omitempty"` + // Type of payload. + Type *HistoricalJobDataType `json:"type,omitempty"` + // 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:"-"` +} + +// NewJobCreateResponseData instantiates a new JobCreateResponseData 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 NewJobCreateResponseData() *JobCreateResponseData { + this := JobCreateResponseData{} + return &this +} + +// NewJobCreateResponseDataWithDefaults instantiates a new JobCreateResponseData 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 NewJobCreateResponseDataWithDefaults() *JobCreateResponseData { + this := JobCreateResponseData{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *JobCreateResponseData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobCreateResponseData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *JobCreateResponseData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *JobCreateResponseData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *JobCreateResponseData) GetType() HistoricalJobDataType { + if o == nil || o.Type == nil { + var ret HistoricalJobDataType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobCreateResponseData) GetTypeOk() (*HistoricalJobDataType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *JobCreateResponseData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given HistoricalJobDataType and assigns it to the Type field. +func (o *JobCreateResponseData) SetType(v HistoricalJobDataType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JobCreateResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JobCreateResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + Type *HistoricalJobDataType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = all.Id + if all.Type != nil && !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_job_definition.go b/api/datadogV2/model_job_definition.go new file mode 100644 index 00000000000..68e5bbef73f --- /dev/null +++ b/api/datadogV2/model_job_definition.go @@ -0,0 +1,547 @@ +// 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" +) + +// JobDefinition Definition of a historical job. +type JobDefinition struct { + // Calculated fields. + CalculatedFields []CalculatedField `json:"calculatedFields,omitempty"` + // Cases used for generating job results. + Cases []SecurityMonitoringRuleCaseCreate `json:"cases"` + // Additional queries to filter matched events before they are processed. This field is deprecated for log detection, signal correlation, and workload security rules. + Filters []SecurityMonitoringFilter `json:"filters,omitempty"` + // Starting time of data analyzed by the job. + From int64 `json:"from"` + // Index used to load the data. + Index string `json:"index"` + // Message for generated results. + Message string `json:"message"` + // Job name. + Name string `json:"name"` + // Options on rules. + Options *SecurityMonitoringRuleOptions `json:"options,omitempty"` + // Queries for selecting logs analyzed by the job. + Queries []SecurityMonitoringStandardRuleQuery `json:"queries"` + // Reference tables for the rule. + ReferenceTables []SecurityMonitoringReferenceTable `json:"referenceTables,omitempty"` + // Tags for generated signals. + Tags []string `json:"tags,omitempty"` + // Cases for generating results from third-party rules. Only available for third-party rules. + ThirdPartyCases []SecurityMonitoringThirdPartyRuleCaseCreate `json:"thirdPartyCases,omitempty"` + // Ending time of data analyzed by the job. + To int64 `json:"to"` + // Job type. + Type *string `json:"type,omitempty"` + // 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:"-"` +} + +// NewJobDefinition instantiates a new JobDefinition 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 NewJobDefinition(cases []SecurityMonitoringRuleCaseCreate, from int64, index string, message string, name string, queries []SecurityMonitoringStandardRuleQuery, to int64) *JobDefinition { + this := JobDefinition{} + this.Cases = cases + this.From = from + this.Index = index + this.Message = message + this.Name = name + this.Queries = queries + this.To = to + return &this +} + +// NewJobDefinitionWithDefaults instantiates a new JobDefinition 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 NewJobDefinitionWithDefaults() *JobDefinition { + this := JobDefinition{} + return &this +} + +// GetCalculatedFields returns the CalculatedFields field value if set, zero value otherwise. +func (o *JobDefinition) GetCalculatedFields() []CalculatedField { + if o == nil || o.CalculatedFields == nil { + var ret []CalculatedField + return ret + } + return o.CalculatedFields +} + +// GetCalculatedFieldsOk returns a tuple with the CalculatedFields field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetCalculatedFieldsOk() (*[]CalculatedField, bool) { + if o == nil || o.CalculatedFields == nil { + return nil, false + } + return &o.CalculatedFields, true +} + +// HasCalculatedFields returns a boolean if a field has been set. +func (o *JobDefinition) HasCalculatedFields() bool { + return o != nil && o.CalculatedFields != nil +} + +// SetCalculatedFields gets a reference to the given []CalculatedField and assigns it to the CalculatedFields field. +func (o *JobDefinition) SetCalculatedFields(v []CalculatedField) { + o.CalculatedFields = v +} + +// GetCases returns the Cases field value. +func (o *JobDefinition) GetCases() []SecurityMonitoringRuleCaseCreate { + if o == nil { + var ret []SecurityMonitoringRuleCaseCreate + return ret + } + return o.Cases +} + +// GetCasesOk returns a tuple with the Cases field value +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetCasesOk() (*[]SecurityMonitoringRuleCaseCreate, bool) { + if o == nil { + return nil, false + } + return &o.Cases, true +} + +// SetCases sets field value. +func (o *JobDefinition) SetCases(v []SecurityMonitoringRuleCaseCreate) { + o.Cases = v +} + +// GetFilters returns the Filters field value if set, zero value otherwise. +func (o *JobDefinition) GetFilters() []SecurityMonitoringFilter { + if o == nil || o.Filters == nil { + var ret []SecurityMonitoringFilter + return ret + } + return o.Filters +} + +// GetFiltersOk returns a tuple with the Filters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetFiltersOk() (*[]SecurityMonitoringFilter, bool) { + if o == nil || o.Filters == nil { + return nil, false + } + return &o.Filters, true +} + +// HasFilters returns a boolean if a field has been set. +func (o *JobDefinition) HasFilters() bool { + return o != nil && o.Filters != nil +} + +// SetFilters gets a reference to the given []SecurityMonitoringFilter and assigns it to the Filters field. +func (o *JobDefinition) SetFilters(v []SecurityMonitoringFilter) { + o.Filters = v +} + +// GetFrom returns the From field value. +func (o *JobDefinition) GetFrom() int64 { + if o == nil { + var ret int64 + return ret + } + return o.From +} + +// GetFromOk returns a tuple with the From field value +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetFromOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.From, true +} + +// SetFrom sets field value. +func (o *JobDefinition) SetFrom(v int64) { + o.From = v +} + +// GetIndex returns the Index field value. +func (o *JobDefinition) GetIndex() string { + if o == nil { + var ret string + return ret + } + return o.Index +} + +// GetIndexOk returns a tuple with the Index field value +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetIndexOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Index, true +} + +// SetIndex sets field value. +func (o *JobDefinition) SetIndex(v string) { + o.Index = v +} + +// GetMessage returns the Message field value. +func (o *JobDefinition) GetMessage() string { + if o == nil { + var ret string + return ret + } + return o.Message +} + +// GetMessageOk returns a tuple with the Message field value +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Message, true +} + +// SetMessage sets field value. +func (o *JobDefinition) SetMessage(v string) { + o.Message = v +} + +// GetName returns the Name field value. +func (o *JobDefinition) 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 *JobDefinition) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *JobDefinition) SetName(v string) { + o.Name = v +} + +// GetOptions returns the Options field value if set, zero value otherwise. +func (o *JobDefinition) GetOptions() SecurityMonitoringRuleOptions { + if o == nil || o.Options == nil { + var ret SecurityMonitoringRuleOptions + return ret + } + return *o.Options +} + +// GetOptionsOk returns a tuple with the Options field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetOptionsOk() (*SecurityMonitoringRuleOptions, bool) { + if o == nil || o.Options == nil { + return nil, false + } + return o.Options, true +} + +// HasOptions returns a boolean if a field has been set. +func (o *JobDefinition) HasOptions() bool { + return o != nil && o.Options != nil +} + +// SetOptions gets a reference to the given SecurityMonitoringRuleOptions and assigns it to the Options field. +func (o *JobDefinition) SetOptions(v SecurityMonitoringRuleOptions) { + o.Options = &v +} + +// GetQueries returns the Queries field value. +func (o *JobDefinition) GetQueries() []SecurityMonitoringStandardRuleQuery { + if o == nil { + var ret []SecurityMonitoringStandardRuleQuery + return ret + } + return o.Queries +} + +// GetQueriesOk returns a tuple with the Queries field value +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetQueriesOk() (*[]SecurityMonitoringStandardRuleQuery, bool) { + if o == nil { + return nil, false + } + return &o.Queries, true +} + +// SetQueries sets field value. +func (o *JobDefinition) SetQueries(v []SecurityMonitoringStandardRuleQuery) { + o.Queries = v +} + +// GetReferenceTables returns the ReferenceTables field value if set, zero value otherwise. +func (o *JobDefinition) GetReferenceTables() []SecurityMonitoringReferenceTable { + if o == nil || o.ReferenceTables == nil { + var ret []SecurityMonitoringReferenceTable + return ret + } + return o.ReferenceTables +} + +// GetReferenceTablesOk returns a tuple with the ReferenceTables field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetReferenceTablesOk() (*[]SecurityMonitoringReferenceTable, bool) { + if o == nil || o.ReferenceTables == nil { + return nil, false + } + return &o.ReferenceTables, true +} + +// HasReferenceTables returns a boolean if a field has been set. +func (o *JobDefinition) HasReferenceTables() bool { + return o != nil && o.ReferenceTables != nil +} + +// SetReferenceTables gets a reference to the given []SecurityMonitoringReferenceTable and assigns it to the ReferenceTables field. +func (o *JobDefinition) SetReferenceTables(v []SecurityMonitoringReferenceTable) { + o.ReferenceTables = v +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *JobDefinition) GetTags() []string { + if o == nil || o.Tags == nil { + var ret []string + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetTagsOk() (*[]string, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return &o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *JobDefinition) HasTags() bool { + return o != nil && o.Tags != nil +} + +// SetTags gets a reference to the given []string and assigns it to the Tags field. +func (o *JobDefinition) SetTags(v []string) { + o.Tags = v +} + +// GetThirdPartyCases returns the ThirdPartyCases field value if set, zero value otherwise. +func (o *JobDefinition) GetThirdPartyCases() []SecurityMonitoringThirdPartyRuleCaseCreate { + if o == nil || o.ThirdPartyCases == nil { + var ret []SecurityMonitoringThirdPartyRuleCaseCreate + return ret + } + return o.ThirdPartyCases +} + +// GetThirdPartyCasesOk returns a tuple with the ThirdPartyCases field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetThirdPartyCasesOk() (*[]SecurityMonitoringThirdPartyRuleCaseCreate, bool) { + if o == nil || o.ThirdPartyCases == nil { + return nil, false + } + return &o.ThirdPartyCases, true +} + +// HasThirdPartyCases returns a boolean if a field has been set. +func (o *JobDefinition) HasThirdPartyCases() bool { + return o != nil && o.ThirdPartyCases != nil +} + +// SetThirdPartyCases gets a reference to the given []SecurityMonitoringThirdPartyRuleCaseCreate and assigns it to the ThirdPartyCases field. +func (o *JobDefinition) SetThirdPartyCases(v []SecurityMonitoringThirdPartyRuleCaseCreate) { + o.ThirdPartyCases = v +} + +// GetTo returns the To field value. +func (o *JobDefinition) GetTo() int64 { + if o == nil { + var ret int64 + return ret + } + return o.To +} + +// GetToOk returns a tuple with the To field value +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetToOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.To, true +} + +// SetTo sets field value. +func (o *JobDefinition) SetTo(v int64) { + o.To = v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *JobDefinition) GetType() string { + if o == nil || o.Type == nil { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobDefinition) GetTypeOk() (*string, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *JobDefinition) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *JobDefinition) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JobDefinition) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CalculatedFields != nil { + toSerialize["calculatedFields"] = o.CalculatedFields + } + toSerialize["cases"] = o.Cases + if o.Filters != nil { + toSerialize["filters"] = o.Filters + } + toSerialize["from"] = o.From + toSerialize["index"] = o.Index + toSerialize["message"] = o.Message + toSerialize["name"] = o.Name + if o.Options != nil { + toSerialize["options"] = o.Options + } + toSerialize["queries"] = o.Queries + if o.ReferenceTables != nil { + toSerialize["referenceTables"] = o.ReferenceTables + } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + if o.ThirdPartyCases != nil { + toSerialize["thirdPartyCases"] = o.ThirdPartyCases + } + toSerialize["to"] = o.To + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JobDefinition) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CalculatedFields []CalculatedField `json:"calculatedFields,omitempty"` + Cases *[]SecurityMonitoringRuleCaseCreate `json:"cases"` + Filters []SecurityMonitoringFilter `json:"filters,omitempty"` + From *int64 `json:"from"` + Index *string `json:"index"` + Message *string `json:"message"` + Name *string `json:"name"` + Options *SecurityMonitoringRuleOptions `json:"options,omitempty"` + Queries *[]SecurityMonitoringStandardRuleQuery `json:"queries"` + ReferenceTables []SecurityMonitoringReferenceTable `json:"referenceTables,omitempty"` + Tags []string `json:"tags,omitempty"` + ThirdPartyCases []SecurityMonitoringThirdPartyRuleCaseCreate `json:"thirdPartyCases,omitempty"` + To *int64 `json:"to"` + Type *string `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Cases == nil { + return fmt.Errorf("required field cases missing") + } + if all.From == nil { + return fmt.Errorf("required field from missing") + } + if all.Index == nil { + return fmt.Errorf("required field index missing") + } + if all.Message == nil { + return fmt.Errorf("required field message missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Queries == nil { + return fmt.Errorf("required field queries missing") + } + if all.To == nil { + return fmt.Errorf("required field to missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"calculatedFields", "cases", "filters", "from", "index", "message", "name", "options", "queries", "referenceTables", "tags", "thirdPartyCases", "to", "type"}) + } else { + return err + } + + hasInvalidField := false + o.CalculatedFields = all.CalculatedFields + o.Cases = *all.Cases + o.Filters = all.Filters + o.From = *all.From + o.Index = *all.Index + o.Message = *all.Message + o.Name = *all.Name + if all.Options != nil && all.Options.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Options = all.Options + o.Queries = *all.Queries + o.ReferenceTables = all.ReferenceTables + o.Tags = all.Tags + o.ThirdPartyCases = all.ThirdPartyCases + o.To = *all.To + 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_job_definition_from_rule.go b/api/datadogV2/model_job_definition_from_rule.go new file mode 100644 index 00000000000..3c115a5f954 --- /dev/null +++ b/api/datadogV2/model_job_definition_from_rule.go @@ -0,0 +1,264 @@ +// 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" +) + +// JobDefinitionFromRule Definition of a historical job based on a security monitoring rule. +type JobDefinitionFromRule struct { + // Index of the rule case applied by the job. + CaseIndex int32 `json:"caseIndex"` + // Starting time of data analyzed by the job. + From int64 `json:"from"` + // ID of the detection rule used to create the job. + Id string `json:"id"` + // Index used to load the data. + Index string `json:"index"` + // Notifications sent when the job is completed. + Notifications []string `json:"notifications,omitempty"` + // Ending time of data analyzed by the job. + To int64 `json:"to"` + // 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:"-"` +} + +// NewJobDefinitionFromRule instantiates a new JobDefinitionFromRule 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 NewJobDefinitionFromRule(caseIndex int32, from int64, id string, index string, to int64) *JobDefinitionFromRule { + this := JobDefinitionFromRule{} + this.CaseIndex = caseIndex + this.From = from + this.Id = id + this.Index = index + this.To = to + return &this +} + +// NewJobDefinitionFromRuleWithDefaults instantiates a new JobDefinitionFromRule 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 NewJobDefinitionFromRuleWithDefaults() *JobDefinitionFromRule { + this := JobDefinitionFromRule{} + return &this +} + +// GetCaseIndex returns the CaseIndex field value. +func (o *JobDefinitionFromRule) GetCaseIndex() int32 { + if o == nil { + var ret int32 + return ret + } + return o.CaseIndex +} + +// GetCaseIndexOk returns a tuple with the CaseIndex field value +// and a boolean to check if the value has been set. +func (o *JobDefinitionFromRule) GetCaseIndexOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.CaseIndex, true +} + +// SetCaseIndex sets field value. +func (o *JobDefinitionFromRule) SetCaseIndex(v int32) { + o.CaseIndex = v +} + +// GetFrom returns the From field value. +func (o *JobDefinitionFromRule) GetFrom() int64 { + if o == nil { + var ret int64 + return ret + } + return o.From +} + +// GetFromOk returns a tuple with the From field value +// and a boolean to check if the value has been set. +func (o *JobDefinitionFromRule) GetFromOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.From, true +} + +// SetFrom sets field value. +func (o *JobDefinitionFromRule) SetFrom(v int64) { + o.From = v +} + +// GetId returns the Id field value. +func (o *JobDefinitionFromRule) 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 *JobDefinitionFromRule) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *JobDefinitionFromRule) SetId(v string) { + o.Id = v +} + +// GetIndex returns the Index field value. +func (o *JobDefinitionFromRule) GetIndex() string { + if o == nil { + var ret string + return ret + } + return o.Index +} + +// GetIndexOk returns a tuple with the Index field value +// and a boolean to check if the value has been set. +func (o *JobDefinitionFromRule) GetIndexOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Index, true +} + +// SetIndex sets field value. +func (o *JobDefinitionFromRule) SetIndex(v string) { + o.Index = v +} + +// GetNotifications returns the Notifications field value if set, zero value otherwise. +func (o *JobDefinitionFromRule) GetNotifications() []string { + if o == nil || o.Notifications == nil { + var ret []string + return ret + } + return o.Notifications +} + +// GetNotificationsOk returns a tuple with the Notifications field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *JobDefinitionFromRule) GetNotificationsOk() (*[]string, bool) { + if o == nil || o.Notifications == nil { + return nil, false + } + return &o.Notifications, true +} + +// HasNotifications returns a boolean if a field has been set. +func (o *JobDefinitionFromRule) HasNotifications() bool { + return o != nil && o.Notifications != nil +} + +// SetNotifications gets a reference to the given []string and assigns it to the Notifications field. +func (o *JobDefinitionFromRule) SetNotifications(v []string) { + o.Notifications = v +} + +// GetTo returns the To field value. +func (o *JobDefinitionFromRule) GetTo() int64 { + if o == nil { + var ret int64 + return ret + } + return o.To +} + +// GetToOk returns a tuple with the To field value +// and a boolean to check if the value has been set. +func (o *JobDefinitionFromRule) GetToOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.To, true +} + +// SetTo sets field value. +func (o *JobDefinitionFromRule) SetTo(v int64) { + o.To = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o JobDefinitionFromRule) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["caseIndex"] = o.CaseIndex + toSerialize["from"] = o.From + toSerialize["id"] = o.Id + toSerialize["index"] = o.Index + if o.Notifications != nil { + toSerialize["notifications"] = o.Notifications + } + toSerialize["to"] = o.To + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *JobDefinitionFromRule) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CaseIndex *int32 `json:"caseIndex"` + From *int64 `json:"from"` + Id *string `json:"id"` + Index *string `json:"index"` + Notifications []string `json:"notifications,omitempty"` + To *int64 `json:"to"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CaseIndex == nil { + return fmt.Errorf("required field caseIndex missing") + } + if all.From == nil { + return fmt.Errorf("required field from missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Index == nil { + return fmt.Errorf("required field index missing") + } + if all.To == nil { + return fmt.Errorf("required field to missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"caseIndex", "from", "id", "index", "notifications", "to"}) + } else { + return err + } + o.CaseIndex = *all.CaseIndex + o.From = *all.From + o.Id = *all.Id + o.Index = *all.Index + o.Notifications = all.Notifications + o.To = *all.To + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_list_historical_jobs_response.go b/api/datadogV2/model_list_historical_jobs_response.go new file mode 100644 index 00000000000..72a437d0ce0 --- /dev/null +++ b/api/datadogV2/model_list_historical_jobs_response.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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListHistoricalJobsResponse List of historical jobs. +type ListHistoricalJobsResponse struct { + // Array containing the list of historical jobs. + Data []HistoricalJobResponseData `json:"data,omitempty"` + // Metadata about the list of jobs. + Meta *HistoricalJobListMeta `json:"meta,omitempty"` + // 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:"-"` +} + +// NewListHistoricalJobsResponse instantiates a new ListHistoricalJobsResponse 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 NewListHistoricalJobsResponse() *ListHistoricalJobsResponse { + this := ListHistoricalJobsResponse{} + return &this +} + +// NewListHistoricalJobsResponseWithDefaults instantiates a new ListHistoricalJobsResponse 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 NewListHistoricalJobsResponseWithDefaults() *ListHistoricalJobsResponse { + this := ListHistoricalJobsResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ListHistoricalJobsResponse) GetData() []HistoricalJobResponseData { + if o == nil || o.Data == nil { + var ret []HistoricalJobResponseData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListHistoricalJobsResponse) GetDataOk() (*[]HistoricalJobResponseData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return &o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *ListHistoricalJobsResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []HistoricalJobResponseData and assigns it to the Data field. +func (o *ListHistoricalJobsResponse) SetData(v []HistoricalJobResponseData) { + o.Data = v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *ListHistoricalJobsResponse) GetMeta() HistoricalJobListMeta { + if o == nil || o.Meta == nil { + var ret HistoricalJobListMeta + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListHistoricalJobsResponse) GetMetaOk() (*HistoricalJobListMeta, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *ListHistoricalJobsResponse) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given HistoricalJobListMeta and assigns it to the Meta field. +func (o *ListHistoricalJobsResponse) SetMeta(v HistoricalJobListMeta) { + o.Meta = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListHistoricalJobsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListHistoricalJobsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []HistoricalJobResponseData `json:"data,omitempty"` + Meta *HistoricalJobListMeta `json:"meta,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "meta"}) + } else { + return err + } + + hasInvalidField := false + o.Data = all.Data + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Meta = all.Meta + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_run_historical_job_request.go b/api/datadogV2/model_run_historical_job_request.go new file mode 100644 index 00000000000..09b1773bdf5 --- /dev/null +++ b/api/datadogV2/model_run_historical_job_request.go @@ -0,0 +1,111 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RunHistoricalJobRequest Run a historical job request. +type RunHistoricalJobRequest struct { + // Data for running a historical job request. + Data *RunHistoricalJobRequestData `json:"data,omitempty"` + // 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:"-"` +} + +// NewRunHistoricalJobRequest instantiates a new RunHistoricalJobRequest 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 NewRunHistoricalJobRequest() *RunHistoricalJobRequest { + this := RunHistoricalJobRequest{} + return &this +} + +// NewRunHistoricalJobRequestWithDefaults instantiates a new RunHistoricalJobRequest 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 NewRunHistoricalJobRequestWithDefaults() *RunHistoricalJobRequest { + this := RunHistoricalJobRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *RunHistoricalJobRequest) GetData() RunHistoricalJobRequestData { + if o == nil || o.Data == nil { + var ret RunHistoricalJobRequestData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RunHistoricalJobRequest) GetDataOk() (*RunHistoricalJobRequestData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *RunHistoricalJobRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given RunHistoricalJobRequestData and assigns it to the Data field. +func (o *RunHistoricalJobRequest) SetData(v RunHistoricalJobRequestData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RunHistoricalJobRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RunHistoricalJobRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *RunHistoricalJobRequestData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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 != nil && 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_run_historical_job_request_attributes.go b/api/datadogV2/model_run_historical_job_request_attributes.go new file mode 100644 index 00000000000..ddbe860d4f4 --- /dev/null +++ b/api/datadogV2/model_run_historical_job_request_attributes.go @@ -0,0 +1,184 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RunHistoricalJobRequestAttributes Run a historical job request. +type RunHistoricalJobRequestAttributes struct { + // Definition of a historical job based on a security monitoring rule. + FromRule *JobDefinitionFromRule `json:"fromRule,omitempty"` + // Request ID. + Id *string `json:"id,omitempty"` + // Definition of a historical job. + JobDefinition *JobDefinition `json:"jobDefinition,omitempty"` + // 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:"-"` +} + +// NewRunHistoricalJobRequestAttributes instantiates a new RunHistoricalJobRequestAttributes 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 NewRunHistoricalJobRequestAttributes() *RunHistoricalJobRequestAttributes { + this := RunHistoricalJobRequestAttributes{} + return &this +} + +// NewRunHistoricalJobRequestAttributesWithDefaults instantiates a new RunHistoricalJobRequestAttributes 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 NewRunHistoricalJobRequestAttributesWithDefaults() *RunHistoricalJobRequestAttributes { + this := RunHistoricalJobRequestAttributes{} + return &this +} + +// GetFromRule returns the FromRule field value if set, zero value otherwise. +func (o *RunHistoricalJobRequestAttributes) GetFromRule() JobDefinitionFromRule { + if o == nil || o.FromRule == nil { + var ret JobDefinitionFromRule + return ret + } + return *o.FromRule +} + +// GetFromRuleOk returns a tuple with the FromRule field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RunHistoricalJobRequestAttributes) GetFromRuleOk() (*JobDefinitionFromRule, bool) { + if o == nil || o.FromRule == nil { + return nil, false + } + return o.FromRule, true +} + +// HasFromRule returns a boolean if a field has been set. +func (o *RunHistoricalJobRequestAttributes) HasFromRule() bool { + return o != nil && o.FromRule != nil +} + +// SetFromRule gets a reference to the given JobDefinitionFromRule and assigns it to the FromRule field. +func (o *RunHistoricalJobRequestAttributes) SetFromRule(v JobDefinitionFromRule) { + o.FromRule = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *RunHistoricalJobRequestAttributes) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RunHistoricalJobRequestAttributes) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *RunHistoricalJobRequestAttributes) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *RunHistoricalJobRequestAttributes) SetId(v string) { + o.Id = &v +} + +// GetJobDefinition returns the JobDefinition field value if set, zero value otherwise. +func (o *RunHistoricalJobRequestAttributes) GetJobDefinition() JobDefinition { + if o == nil || o.JobDefinition == nil { + var ret JobDefinition + return ret + } + return *o.JobDefinition +} + +// GetJobDefinitionOk returns a tuple with the JobDefinition field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RunHistoricalJobRequestAttributes) GetJobDefinitionOk() (*JobDefinition, bool) { + if o == nil || o.JobDefinition == nil { + return nil, false + } + return o.JobDefinition, true +} + +// HasJobDefinition returns a boolean if a field has been set. +func (o *RunHistoricalJobRequestAttributes) HasJobDefinition() bool { + return o != nil && o.JobDefinition != nil +} + +// SetJobDefinition gets a reference to the given JobDefinition and assigns it to the JobDefinition field. +func (o *RunHistoricalJobRequestAttributes) SetJobDefinition(v JobDefinition) { + o.JobDefinition = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RunHistoricalJobRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.FromRule != nil { + toSerialize["fromRule"] = o.FromRule + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.JobDefinition != nil { + toSerialize["jobDefinition"] = o.JobDefinition + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RunHistoricalJobRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + FromRule *JobDefinitionFromRule `json:"fromRule,omitempty"` + Id *string `json:"id,omitempty"` + JobDefinition *JobDefinition `json:"jobDefinition,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"fromRule", "id", "jobDefinition"}) + } else { + return err + } + + hasInvalidField := false + if all.FromRule != nil && all.FromRule.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.FromRule = all.FromRule + o.Id = all.Id + if all.JobDefinition != nil && all.JobDefinition.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.JobDefinition = all.JobDefinition + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_run_historical_job_request_data.go b/api/datadogV2/model_run_historical_job_request_data.go new file mode 100644 index 00000000000..15e2baa742d --- /dev/null +++ b/api/datadogV2/model_run_historical_job_request_data.go @@ -0,0 +1,150 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RunHistoricalJobRequestData Data for running a historical job request. +type RunHistoricalJobRequestData struct { + // Run a historical job request. + Attributes *RunHistoricalJobRequestAttributes `json:"attributes,omitempty"` + // Type of data. + Type *RunHistoricalJobRequestDataType `json:"type,omitempty"` + // 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:"-"` +} + +// NewRunHistoricalJobRequestData instantiates a new RunHistoricalJobRequestData 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 NewRunHistoricalJobRequestData() *RunHistoricalJobRequestData { + this := RunHistoricalJobRequestData{} + return &this +} + +// NewRunHistoricalJobRequestDataWithDefaults instantiates a new RunHistoricalJobRequestData 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 NewRunHistoricalJobRequestDataWithDefaults() *RunHistoricalJobRequestData { + this := RunHistoricalJobRequestData{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *RunHistoricalJobRequestData) GetAttributes() RunHistoricalJobRequestAttributes { + if o == nil || o.Attributes == nil { + var ret RunHistoricalJobRequestAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RunHistoricalJobRequestData) GetAttributesOk() (*RunHistoricalJobRequestAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *RunHistoricalJobRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given RunHistoricalJobRequestAttributes and assigns it to the Attributes field. +func (o *RunHistoricalJobRequestData) SetAttributes(v RunHistoricalJobRequestAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *RunHistoricalJobRequestData) GetType() RunHistoricalJobRequestDataType { + if o == nil || o.Type == nil { + var ret RunHistoricalJobRequestDataType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RunHistoricalJobRequestData) GetTypeOk() (*RunHistoricalJobRequestDataType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *RunHistoricalJobRequestData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given RunHistoricalJobRequestDataType and assigns it to the Type field. +func (o *RunHistoricalJobRequestData) SetType(v RunHistoricalJobRequestDataType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RunHistoricalJobRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RunHistoricalJobRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *RunHistoricalJobRequestAttributes `json:"attributes,omitempty"` + Type *RunHistoricalJobRequestDataType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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 != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if all.Type != nil && !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_run_historical_job_request_data_type.go b/api/datadogV2/model_run_historical_job_request_data_type.go new file mode 100644 index 00000000000..b89c9fb60cf --- /dev/null +++ b/api/datadogV2/model_run_historical_job_request_data_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" +) + +// RunHistoricalJobRequestDataType Type of data. +type RunHistoricalJobRequestDataType string + +// List of RunHistoricalJobRequestDataType. +const ( + RUNHISTORICALJOBREQUESTDATATYPE_HISTORICALDETECTIONSJOBCREATE RunHistoricalJobRequestDataType = "historicalDetectionsJobCreate" +) + +var allowedRunHistoricalJobRequestDataTypeEnumValues = []RunHistoricalJobRequestDataType{ + RUNHISTORICALJOBREQUESTDATATYPE_HISTORICALDETECTIONSJOBCREATE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *RunHistoricalJobRequestDataType) GetAllowedValues() []RunHistoricalJobRequestDataType { + return allowedRunHistoricalJobRequestDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *RunHistoricalJobRequestDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = RunHistoricalJobRequestDataType(value) + return nil +} + +// NewRunHistoricalJobRequestDataTypeFromValue returns a pointer to a valid RunHistoricalJobRequestDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewRunHistoricalJobRequestDataTypeFromValue(v string) (*RunHistoricalJobRequestDataType, error) { + ev := RunHistoricalJobRequestDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for RunHistoricalJobRequestDataType: valid values are %v", v, allowedRunHistoricalJobRequestDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v RunHistoricalJobRequestDataType) IsValid() bool { + for _, existing := range allowedRunHistoricalJobRequestDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to RunHistoricalJobRequestDataType value. +func (v RunHistoricalJobRequestDataType) Ptr() *RunHistoricalJobRequestDataType { + return &v +} diff --git a/examples/v2/security-monitoring/CancelHistoricalJob.go b/examples/v2/security-monitoring/CancelHistoricalJob.go new file mode 100644 index 00000000000..b1c51df4a8b --- /dev/null +++ b/examples/v2/security-monitoring/CancelHistoricalJob.go @@ -0,0 +1,30 @@ +// Cancel a historical job returns "OK" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "historical_job" in the system + HistoricalJobDataID := os.Getenv("HISTORICAL_JOB_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.RunHistoricalJob", true) + configuration.SetUnstableOperationEnabled("v2.CancelHistoricalJob", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + r, err := api.CancelHistoricalJob(ctx, HistoricalJobDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.CancelHistoricalJob`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/security-monitoring/ConvertJobResultToSignal.go b/examples/v2/security-monitoring/ConvertJobResultToSignal.go new file mode 100644 index 00000000000..90e0e289a94 --- /dev/null +++ b/examples/v2/security-monitoring/ConvertJobResultToSignal.go @@ -0,0 +1,41 @@ +// Convert a job result to a signal returns "OK" response + +package main + +import ( + "context" + "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.ConvertJobResultsToSignalsRequest{ + Data: &datadogV2.ConvertJobResultsToSignalsData{ + Attributes: &datadogV2.ConvertJobResultsToSignalsAttributes{ + JobResultIds: []string{ + "", + }, + Notifications: []string{ + "", + }, + SignalMessage: "A large number of failed login attempts.", + SignalSeverity: datadogV2.SECURITYMONITORINGRULESEVERITY_CRITICAL, + }, + Type: datadogV2.CONVERTJOBRESULTSTOSIGNALSDATATYPE_HISTORICALDETECTIONSJOBRESULTSIGNALCONVERSION.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ConvertJobResultToSignal", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + r, err := api.ConvertJobResultToSignal(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.ConvertJobResultToSignal`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/security-monitoring/DeleteHistoricalJob.go b/examples/v2/security-monitoring/DeleteHistoricalJob.go new file mode 100644 index 00000000000..1a2d77d4e76 --- /dev/null +++ b/examples/v2/security-monitoring/DeleteHistoricalJob.go @@ -0,0 +1,26 @@ +// Delete an existing job returns "OK" response + +package main + +import ( + "context" + "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.DeleteHistoricalJob", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + r, err := api.DeleteHistoricalJob(ctx, "job_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.DeleteHistoricalJob`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/security-monitoring/GetHistoricalJob.go b/examples/v2/security-monitoring/GetHistoricalJob.go new file mode 100644 index 00000000000..8f161e2a0b3 --- /dev/null +++ b/examples/v2/security-monitoring/GetHistoricalJob.go @@ -0,0 +1,34 @@ +// Get a job's details 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() { + // there is a valid "historical_job" in the system + HistoricalJobDataID := os.Getenv("HISTORICAL_JOB_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.RunHistoricalJob", true) + configuration.SetUnstableOperationEnabled("v2.GetHistoricalJob", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.GetHistoricalJob(ctx, HistoricalJobDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.GetHistoricalJob`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.GetHistoricalJob`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/ListHistoricalJobs.go b/examples/v2/security-monitoring/ListHistoricalJobs.go new file mode 100644 index 00000000000..c7732ad0231 --- /dev/null +++ b/examples/v2/security-monitoring/ListHistoricalJobs.go @@ -0,0 +1,33 @@ +// List historical jobs 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() { + // there is a valid "historical_job" in the system + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.RunHistoricalJob", true) + configuration.SetUnstableOperationEnabled("v2.ListHistoricalJobs", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.ListHistoricalJobs(ctx, *datadogV2.NewListHistoricalJobsOptionalParameters().WithFilterQuery("id:string")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.ListHistoricalJobs`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.ListHistoricalJobs`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/RunHistoricalJob.go b/examples/v2/security-monitoring/RunHistoricalJob.go new file mode 100644 index 00000000000..2daa5ec761c --- /dev/null +++ b/examples/v2/security-monitoring/RunHistoricalJob.go @@ -0,0 +1,67 @@ +// Run a historical job returns "Status created" 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.RunHistoricalJobRequest{ + Data: &datadogV2.RunHistoricalJobRequestData{ + Type: datadogV2.RUNHISTORICALJOBREQUESTDATATYPE_HISTORICALDETECTIONSJOBCREATE.Ptr(), + Attributes: &datadogV2.RunHistoricalJobRequestAttributes{ + JobDefinition: &datadogV2.JobDefinition{ + Type: datadog.PtrString("log_detection"), + Name: "Excessive number of failed attempts.", + Queries: []datadogV2.SecurityMonitoringStandardRuleQuery{ + { + Query: datadog.PtrString("source:non_existing_src_weekend"), + Aggregation: datadogV2.SECURITYMONITORINGRULEQUERYAGGREGATION_COUNT.Ptr(), + GroupByFields: []string{}, + DistinctFields: []string{}, + }, + }, + Cases: []datadogV2.SecurityMonitoringRuleCaseCreate{ + { + Name: datadog.PtrString("Condition 1"), + Status: datadogV2.SECURITYMONITORINGRULESEVERITY_INFO, + Notifications: []string{}, + Condition: datadog.PtrString("a > 1"), + }, + }, + Options: &datadogV2.SecurityMonitoringRuleOptions{ + KeepAlive: datadogV2.SECURITYMONITORINGRULEKEEPALIVE_ONE_HOUR.Ptr(), + MaxSignalDuration: datadogV2.SECURITYMONITORINGRULEMAXSIGNALDURATION_ONE_DAY.Ptr(), + EvaluationWindow: datadogV2.SECURITYMONITORINGRULEEVALUATIONWINDOW_FIFTEEN_MINUTES.Ptr(), + }, + Message: "A large number of failed login attempts.", + Tags: []string{}, + From: 1730387522611, + To: 1730387532611, + Index: "main", + }, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.RunHistoricalJob", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.RunHistoricalJob(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.RunHistoricalJob`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.RunHistoricalJob`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..bf92f15d9de --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:38.539Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..5d008597155 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Bad_Request_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs/inva-lid/cancel + response: + body: '{"errors":[{"status":"400","detail":"invalid jobId"}]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..8bf8faeef38 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:39.006Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..8494055a81e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_Not_Found_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs/8e2a37fb-b0c8-4761-a7f0-0a8d6a98ba93/cancel + response: + body: '{"errors":[{"status":"404","title":"Not Found","detail":"Job 8e2a37fb-b0c8-4761-a7f0-0a8d6a98ba93 + was not found."}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_OK_response.freeze new file mode 100644 index 00000000000..8eee63f586c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:39.082Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_OK_response.yaml new file mode 100644 index 00000000000..9d4ed51e7d2 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Cancel_a_historical_job_returns_OK_response.yaml @@ -0,0 +1,37 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"jobDefinition":{"cases":[{"condition":"a \u003e 1","name":"Condition 1","notifications":[],"status":"info"}],"from":1730387522611,"index":"main","message":"A large number of failed login attempts.","name":"Excessive number of failed attempts.","options":{"evaluationWindow":900,"keepAlive":3600,"maxSignalDuration":86400},"queries":[{"aggregation":"count","distinctFields":[],"groupByFields":[],"query":"source:non_existing_src_weekend"}],"tags":[],"to":1730387532611,"type":"log_detection"}},"type":"historicalDetectionsJobCreate"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs + response: + body: '{"data":{"id":"e332b07e-d573-45fa-b2df-9a1bcc27f17e","type":"historicalDetectionsJob"}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs/e332b07e-d573-45fa-b2df-9a1bcc27f17e/cancel + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Convert_a_job_result_to_a_signal_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Convert_a_job_result_to_a_signal_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..b819957f316 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Convert_a_job_result_to_a_signal_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:39.280Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Convert_a_job_result_to_a_signal_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Convert_a_job_result_to_a_signal_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..213219d6a85 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Convert_a_job_result_to_a_signal_returns_Bad_Request_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"jobResultIds":[""],"notifications":[""],"signalMessage":"A large number of failed login attempts.","signalSeverity":"critical"},"type":"historicalDetectionsJobResultSignalConversion"}} + form: {} + headers: + Accept: + - '*/*' + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs/signal_convert + response: + body: '{"errors":[{"status":"400","title":"Generic Error","detail":"empty jobResultId + provided"}]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..553556ed2e1 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:39.371Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..66eb1570ebc --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Bad_Request_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: DELETE + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs/inva-lid + response: + body: '{"errors":[{"status":"400","title":"Generic Error","detail":"invalid jobId"}]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..e02fd6acb10 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:39.455Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..727056e2169 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Delete_an_existing_job_returns_Not_Found_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: DELETE + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs/8e2a37fb-b0c8-4761-a7f0-0a8d6a98ba93 + response: + body: '{"errors":[{"status":"404","title":"Not Found","detail":"Job 8e2a37fb-b0c8-4761-a7f0-0a8d6a98ba93 + was not found."}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..14e96034851 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:39.538Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..9da1f83a915 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Bad_Request_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/siem-historical-detections/jobs/inva-lid + response: + body: '{"errors":[{"status":"400","detail":"invalid jobId"}]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..5cc9a16c879 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:39.611Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..ee14b84c19c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_Not_Found_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs/8e2a37fb-b0c8-4761-a7f0-0a8d6a98ba93 + response: + body: '{"errors":[{"status":"404","title":"Not Found","detail":"Job 8e2a37fb-b0c8-4761-a7f0-0a8d6a98ba93 + was not found."}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_OK_response.freeze new file mode 100644 index 00000000000..f25fc13ebb0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:39.695Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_OK_response.yaml new file mode 100644 index 00000000000..3c693d3cb31 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Get_a_jobs_details_returns_OK_response.yaml @@ -0,0 +1,45 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"jobDefinition":{"cases":[{"condition":"a \u003e 1","name":"Condition 1","notifications":[],"status":"info"}],"from":1730387522611,"index":"main","message":"A large number of failed login attempts.","name":"Excessive number of failed attempts.","options":{"evaluationWindow":900,"keepAlive":3600,"maxSignalDuration":86400},"queries":[{"aggregation":"count","distinctFields":[],"groupByFields":[],"query":"source:non_existing_src_weekend"}],"tags":[],"to":1730387532611,"type":"log_detection"}},"type":"historicalDetectionsJobCreate"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs + response: + body: '{"data":{"id":"f1753ed6-8c47-4168-9d6b-d11b9612fb3c","type":"historicalDetectionsJob"}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs/f1753ed6-8c47-4168-9d6b-d11b9612fb3c + response: + body: '{"data":{"id":"f1753ed6-8c47-4168-9d6b-d11b9612fb3c","type":"historicalDetectionsJob","attributes":{"createdAt":"2024-11-08 + 09:54:39.761792+00","createdByHandle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","createdByName":"CI + Account","jobDefinition":{"from":1730387522611,"to":1730387532611,"index":"main","name":"Excessive + number of failed attempts.","cases":[{"name":"Condition 1","status":"info","notifications":[],"condition":"a + \u003e 1"}],"queries":[{"query":"source:non_existing_src_weekend","groupByFields":[],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":""}],"options":{"evaluationWindow":900,"detectionMethod":"threshold","maxSignalDuration":86400,"keepAlive":3600},"message":"A + large number of failed login attempts.","tags":[],"type":"log_detection","filters":[]},"jobName":"Excessive + number of failed attempts.","jobStatus":"pending","modifiedAt":"2024-11-08 09:54:39.761792+00"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_historical_jobs_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_historical_jobs_returns_OK_response.freeze new file mode 100644 index 00000000000..b45a44cb78f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_historical_jobs_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:39.932Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_historical_jobs_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_historical_jobs_returns_OK_response.yaml new file mode 100644 index 00000000000..c6146040030 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_historical_jobs_returns_OK_response.yaml @@ -0,0 +1,45 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"jobDefinition":{"cases":[{"condition":"a \u003e 1","name":"Condition 1","notifications":[],"status":"info"}],"from":1730387522611,"index":"main","message":"A large number of failed login attempts.","name":"Excessive number of failed attempts.","options":{"evaluationWindow":900,"keepAlive":3600,"maxSignalDuration":86400},"queries":[{"aggregation":"count","distinctFields":[],"groupByFields":[],"query":"source:non_existing_src_weekend"}],"tags":[],"to":1730387532611,"type":"log_detection"}},"type":"historicalDetectionsJobCreate"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs + response: + body: '{"data":{"id":"34df4a54-9d84-4b4c-bc7e-0464d374ee19","type":"historicalDetectionsJob"}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs?filter%5Bquery%5D=id%3A34df4a54-9d84-4b4c-bc7e-0464d374ee19 + response: + body: '{"data":[{"id":"34df4a54-9d84-4b4c-bc7e-0464d374ee19","type":"historicalDetectionsJob","attributes":{"createdAt":"2024-11-08 + 09:54:40.000915+00","createdByHandle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","createdByName":"CI + Account","jobDefinition":{"from":1730387522611,"to":1730387532611,"index":"main","name":"Excessive + number of failed attempts.","cases":[{"name":"Condition 1","status":"info","notifications":[],"condition":"a + \u003e 1"}],"queries":[{"query":"source:non_existing_src_weekend","groupByFields":[],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":""}],"options":{"evaluationWindow":900,"detectionMethod":"threshold","maxSignalDuration":86400,"keepAlive":3600},"message":"A + large number of failed login attempts.","tags":[],"type":"log_detection","filters":[]},"jobName":"Excessive + number of failed attempts.","jobStatus":"pending","modifiedAt":"2024-11-08 09:54:40.000915+00"}}],"meta":{"totalCount":1}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..9720094d000 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:40.114Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..d7ecf97f3d6 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Bad_Request_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"jobDefinition":{"cases":[{"condition":"a \u003e 1","name":"Condition 1","notifications":[],"status":"info"}],"from":1730387522611,"index":"non_existing_index","message":"A large number of failed login attempts.","name":"Excessive number of failed attempts.","options":{"evaluationWindow":900,"keepAlive":3600,"maxSignalDuration":86400},"queries":[{"aggregation":"count","distinctFields":[],"groupByFields":[],"query":"source:non_existing_src_weekend"}],"tags":[],"to":1730391122611,"type":"log_detection"}},"type":"historicalDetectionsJobCreate"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs + response: + body: '{"errors":["input_validation_error(Field ''index'' is invalid: Invalid + index): Index must exist"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..ee3fdb952b3 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:40.192Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..3aae65bf0c0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Not_Found_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"fromRule":{"caseIndex":0,"from":1730201035064,"id":"non-existng","index":"main","notifications":[],"to":1730204635115}},"type":"historicalDetectionsJobCreate"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs + response: + body: '{"errors":[{"status":"404","detail":"failed to get rule details"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Status_created_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Status_created_response.freeze new file mode 100644 index 00000000000..3e9fdecb999 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Status_created_response.freeze @@ -0,0 +1 @@ +2024-11-08T09:54:40.272Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Status_created_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Status_created_response.yaml new file mode 100644 index 00000000000..0945edbd6fd --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Run_a_historical_job_returns_Status_created_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"jobDefinition":{"cases":[{"condition":"a \u003e 1","name":"Condition 1","notifications":[],"status":"info"}],"from":1730387522611,"index":"main","message":"A large number of failed login attempts.","name":"Excessive number of failed attempts.","options":{"evaluationWindow":900,"keepAlive":3600,"maxSignalDuration":86400},"queries":[{"aggregation":"count","distinctFields":[],"groupByFields":[],"query":"source:non_existing_src_weekend"}],"tags":[],"to":1730387532611,"type":"log_detection"}},"type":"historicalDetectionsJobCreate"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/siem-historical-detections/jobs + response: + body: '{"data":{"id":"6f4c9c40-782b-4d14-900f-65ccc02389db","type":"historicalDetectionsJob"}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +version: 2 diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index d5a158b247b..6271eb23f01 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -649,6 +649,18 @@ "tag": "Service Definition", "operationId": "CreateOrUpdateServiceDefinitions" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"historicalDetectionsJobCreate\",\n \"attributes\": {\n \"jobDefinition\": {\n \"type\": \"log_detection\",\n \"name\": \"Excessive number of failed attempts.\",\n \"queries\": [\n {\n \"query\": \"source:non_existing_src_weekend\",\n \"aggregation\": \"count\",\n \"groupByFields\": [],\n \"distinctFields\": []\n }\n ],\n \"cases\": [\n {\n \"name\": \"Condition 1\",\n \"status\": \"info\",\n \"notifications\": [],\n \"condition\": \"a > 1\"\n }\n ],\n \"options\": {\n \"keepAlive\": 3600,\n \"maxSignalDuration\": 86400,\n \"evaluationWindow\": 900\n },\n \"message\": \"A large number of failed login attempts.\",\n \"tags\": [],\n \"from\": 1730387522611,\n \"to\": 1730387532611,\n \"index\": \"main\"\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"historical_job\" in the system", + "key": "historical_job", + "tag": "Security Monitoring", + "operationId": "RunHistoricalJob" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/security_monitoring.feature b/tests/scenarios/features/v2/security_monitoring.feature index 901edb86b49..a2d77f04939 100644 --- a/tests/scenarios/features/v2/security_monitoring.feature +++ b/tests/scenarios/features/v2/security_monitoring.feature @@ -9,6 +9,40 @@ Feature: Security Monitoring And a valid "appKeyAuth" key in the system And an instance of "SecurityMonitoring" API + @team:DataDog/k9-cloud-security-platform + Scenario: Cancel a historical job returns "Bad Request" response + Given operation "CancelHistoricalJob" enabled + And new "CancelHistoricalJob" request + And request contains "job_id" parameter with value "inva-lid" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: Cancel a historical job returns "Conflict" response + Given operation "CancelHistoricalJob" enabled + And new "CancelHistoricalJob" request + And request contains "job_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Conflict + + @team:DataDog/k9-cloud-security-platform + Scenario: Cancel a historical job returns "Not Found" response + Given operation "CancelHistoricalJob" enabled + And new "CancelHistoricalJob" request + And request contains "job_id" parameter with value "8e2a37fb-b0c8-4761-a7f0-0a8d6a98ba93" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/k9-cloud-security-platform + Scenario: Cancel a historical job returns "OK" response + Given operation "CancelHistoricalJob" enabled + And operation "RunHistoricalJob" enabled + And new "CancelHistoricalJob" request + And there is a valid "historical_job" in the system + And request contains "job_id" parameter from "historical_job.data.id" + When the request is sent + Then the response status is 204 No Content + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: Change the related incidents of a security signal returns "Bad Request" response Given new "EditSecurityMonitoringSignalIncidents" request @@ -57,6 +91,30 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @team:DataDog/k9-cloud-security-platform + Scenario: Convert a job result to a signal returns "Bad Request" response + Given operation "ConvertJobResultToSignal" enabled + And new "ConvertJobResultToSignal" request + And body with value {"data": {"attributes": {"jobResultIds": [""], "notifications": [""], "signalMessage": "A large number of failed login attempts.", "signalSeverity": "critical"}, "type": "historicalDetectionsJobResultSignalConversion"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: Convert a job result to a signal returns "Not Found" response + Given operation "ConvertJobResultToSignal" enabled + And new "ConvertJobResultToSignal" request + And body with value {"data": {"attributes": {"jobResultIds": [""], "notifications": [""], "signalMessage": "A large number of failed login attempts.", "signalSeverity": "critical"}, "type": "historicalDetectionsJobResultSignalConversion"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: Convert a job result to a signal returns "OK" response + Given operation "ConvertJobResultToSignal" enabled + And new "ConvertJobResultToSignal" request + And body with value {"data": {"attributes": {"jobResultIds": [""], "notifications": [""], "signalMessage": "A large number of failed login attempts.", "signalSeverity": "critical"}, "type": "historicalDetectionsJobResultSignalConversion"}} + When the request is sent + Then the response status is 204 OK + @skip @team:DataDog/k9-cloud-security-platform Scenario: Convert a rule from JSON to Terraform returns "Bad Request" response Given new "ConvertSecurityMonitoringRuleFromJSONToTerraform" request @@ -282,6 +340,38 @@ Feature: Security Monitoring When the request is sent Then the response status is 204 OK + @team:DataDog/k9-cloud-security-platform + Scenario: Delete an existing job returns "Bad Request" response + Given operation "DeleteHistoricalJob" enabled + And new "DeleteHistoricalJob" request + And request contains "job_id" parameter with value "inva-lid" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: Delete an existing job returns "Conflict" response + Given operation "DeleteHistoricalJob" enabled + And new "DeleteHistoricalJob" request + And request contains "job_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Conflict + + @team:DataDog/k9-cloud-security-platform + Scenario: Delete an existing job returns "Not Found" response + Given operation "DeleteHistoricalJob" enabled + And new "DeleteHistoricalJob" request + And request contains "job_id" parameter with value "8e2a37fb-b0c8-4761-a7f0-0a8d6a98ba93" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: Delete an existing job returns "OK" response + Given operation "DeleteHistoricalJob" enabled + And new "DeleteHistoricalJob" request + And request contains "job_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 OK + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: Delete an existing rule returns "Not Found" response Given new "DeleteSecurityMonitoringRule" request @@ -332,6 +422,32 @@ Feature: Security Monitoring Then the response status is 200 OK And the response "data.attributes.evaluation" is equal to "pass" + @team:DataDog/k9-cloud-security-platform + Scenario: Get a job's details returns "Bad Request" response + Given operation "GetHistoricalJob" enabled + And new "GetHistoricalJob" request + And request contains "job_id" parameter with value "inva-lid" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/k9-cloud-security-platform + Scenario: Get a job's details returns "Not Found" response + Given operation "GetHistoricalJob" enabled + And new "GetHistoricalJob" request + And request contains "job_id" parameter with value "8e2a37fb-b0c8-4761-a7f0-0a8d6a98ba93" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/k9-cloud-security-platform + Scenario: Get a job's details returns "OK" response + Given operation "GetHistoricalJob" enabled + And operation "RunHistoricalJob" enabled + And new "GetHistoricalJob" request + And there is a valid "historical_job" in the system + And request contains "job_id" parameter from "historical_job.data.id" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: Get a list of security signals returns "Bad Request" response Given new "SearchSecurityMonitoringSignals" request @@ -493,6 +609,23 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: List historical jobs returns "Bad Request" response + Given operation "ListHistoricalJobs" enabled + And new "ListHistoricalJobs" request + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/k9-cloud-security-platform + Scenario: List historical jobs returns "OK" response + Given operation "ListHistoricalJobs" enabled + And operation "RunHistoricalJob" enabled + And new "ListHistoricalJobs" request + And there is a valid "historical_job" in the system + And request contains "filter[query]" parameter with value "id:{{historical_job.data.id}}" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: List rules returns "Bad Request" response Given new "ListSecurityMonitoringRules" request @@ -561,6 +694,30 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @team:DataDog/k9-cloud-security-platform + Scenario: Run a historical job returns "Bad Request" response + Given operation "RunHistoricalJob" enabled + And new "RunHistoricalJob" request + And body with value {"data":{"type":"historicalDetectionsJobCreate","attributes":{"jobDefinition":{"type":"log_detection","name":"Excessive number of failed attempts.","queries":[{"query":"source:non_existing_src_weekend","aggregation":"count","groupByFields":[],"distinctFields":[]}],"cases":[{"name":"Condition 1","status":"info","notifications":[],"condition":"a > 1"}],"options":{"keepAlive":3600,"maxSignalDuration":86400,"evaluationWindow":900},"message":"A large number of failed login attempts.","tags":[],"from":1730387522611,"to":1730391122611,"index":"non_existing_index"}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/k9-cloud-security-platform + Scenario: Run a historical job returns "Not Found" response + Given operation "RunHistoricalJob" enabled + And new "RunHistoricalJob" request + And body with value {"data": { "type": "historicalDetectionsJobCreate", "attributes": {"fromRule": {"caseIndex": 0, "from": 1730201035064, "id": "non-existng", "index": "main", "notifications": [], "to": 1730204635115}}}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/k9-cloud-security-platform + Scenario: Run a historical job returns "Status created" response + Given operation "RunHistoricalJob" enabled + And new "RunHistoricalJob" request + And body with value {"data":{"type":"historicalDetectionsJobCreate","attributes":{"jobDefinition":{"type":"log_detection","name":"Excessive number of failed attempts.","queries":[{"query":"source:non_existing_src_weekend","aggregation":"count","groupByFields":[],"distinctFields":[]}],"cases":[{"name":"Condition 1","status":"info","notifications":[],"condition":"a > 1"}],"options":{"keepAlive":3600,"maxSignalDuration":86400,"evaluationWindow":900},"message":"A large number of failed login attempts.","tags":[],"from":1730387522611,"to":1730387532611,"index":"main"}}}} + When the request is sent + Then the response status is 201 Status created + @skip @team:DataDog/k9-cloud-security-platform Scenario: Test a rule returns "Bad Request" response Given new "TestSecurityMonitoringRule" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 81c6a29e22c..0e2a5942a9d 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2272,6 +2272,42 @@ "type": "idempotent" } }, + "ListHistoricalJobs": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "RunHistoricalJob": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "ConvertJobResultToSignal": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "DeleteHistoricalJob": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "GetHistoricalJob": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "CancelHistoricalJob": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, "CreateSLOReportJob": { "tag": "Service Level Objectives", "undo": {