diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 478df242ef8..4c46f3c596f 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -71565,6 +71565,416 @@ components: $ref: "#/components/schemas/SyntheticsApiMultistepSubtestData" type: array type: object + SyntheticsDowntimeData: + description: A Synthetics downtime object. + properties: + attributes: + $ref: "#/components/schemas/SyntheticsDowntimeDataAttributesResponse" + id: + description: The unique identifier of the downtime. + example: "00000000-0000-0000-0000-000000000001" + type: string + type: + $ref: "#/components/schemas/SyntheticsDowntimeResourceType" + required: + - id + - type + - attributes + type: object + SyntheticsDowntimeDataAttributesRequest: + description: Attributes for creating or updating a Synthetics downtime. + properties: + description: + description: An optional description of the downtime. + example: Scheduled weekly maintenance window. + type: string + isEnabled: + description: Whether the downtime is enabled. + example: true + type: boolean + name: + description: The name of the downtime. + example: Weekly maintenance + type: string + tags: + $ref: "#/components/schemas/SyntheticsDowntimeTags" + testIds: + $ref: "#/components/schemas/SyntheticsDowntimeTestIds" + timeSlots: + $ref: "#/components/schemas/SyntheticsDowntimeTimeSlotRequests" + required: + - name + - isEnabled + - timeSlots + - testIds + type: object + SyntheticsDowntimeDataAttributesResponse: + description: Attributes of a Synthetics downtime response object. + properties: + createdAt: + description: The timestamp when the downtime was created. + example: "2024-01-15T10:30:00Z" + format: date-time + type: string + createdBy: + description: The UUID of the user who created the downtime. + example: "00000000-0000-0000-0000-000000000003" + type: string + createdByName: + description: The display name of the user who created the downtime. + example: Jane Doe + type: string + description: + description: The description of the downtime. + example: Scheduled weekly maintenance window. + type: string + isEnabled: + description: Whether the downtime is enabled. + example: true + type: boolean + name: + description: The name of the downtime. + example: Weekly maintenance + type: string + tags: + $ref: "#/components/schemas/SyntheticsDowntimeTags" + testIds: + $ref: "#/components/schemas/SyntheticsDowntimeTestIds" + timeSlots: + $ref: "#/components/schemas/SyntheticsDowntimeTimeSlotResponses" + updatedAt: + description: The timestamp when the downtime was last updated. + example: "2024-01-15T10:30:00Z" + format: date-time + type: string + updatedBy: + description: The UUID of the user who last updated the downtime. + example: "00000000-0000-0000-0000-000000000003" + type: string + updatedByName: + description: The display name of the user who last updated the downtime. + example: Jane Doe + type: string + required: + - name + - description + - isEnabled + - createdBy + - createdByName + - createdAt + - updatedBy + - updatedByName + - updatedAt + - timeSlots + - testIds + - tags + type: object + SyntheticsDowntimeDataList: + description: List of Synthetics downtime objects. + example: + - attributes: + createdAt: "2024-01-15T10:30:00Z" + createdBy: "00000000-0000-0000-0000-000000000003" + createdByName: Jane Doe + description: Scheduled weekly maintenance window. + isEnabled: true + name: Weekly maintenance + tags: [] + testIds: + - abc-def-123 + timeSlots: + - duration: 3600 + id: "00000000-0000-0000-0000-000000000002" + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + updatedAt: "2024-01-15T10:30:00Z" + updatedBy: "00000000-0000-0000-0000-000000000003" + updatedByName: Jane Doe + id: "00000000-0000-0000-0000-000000000001" + type: downtime + items: + $ref: "#/components/schemas/SyntheticsDowntimeData" + type: array + SyntheticsDowntimeDataRequest: + description: The data object for a Synthetics downtime create or update request. + example: + attributes: + isEnabled: true + name: Weekly maintenance + testIds: + - abc-def-123 + timeSlots: + - duration: 3600 + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + type: downtime + properties: + attributes: + $ref: "#/components/schemas/SyntheticsDowntimeDataAttributesRequest" + type: + $ref: "#/components/schemas/SyntheticsDowntimeResourceType" + required: + - type + - attributes + type: object + SyntheticsDowntimeFrequency: + description: The recurrence frequency of a Synthetics downtime time slot. + enum: + - DAILY + - WEEKLY + - MONTHLY + - YEARLY + example: WEEKLY + type: string + x-enum-varnames: + - DAILY + - WEEKLY + - MONTHLY + - YEARLY + SyntheticsDowntimeRequest: + description: Request body for creating or updating a Synthetics downtime. + properties: + data: + $ref: "#/components/schemas/SyntheticsDowntimeDataRequest" + required: + - data + type: object + SyntheticsDowntimeResourceType: + description: The resource type for a Synthetics downtime. + enum: + - downtime + example: downtime + type: string + x-enum-varnames: + - DOWNTIME + SyntheticsDowntimeResponse: + description: Response containing a single Synthetics downtime. + properties: + data: + $ref: "#/components/schemas/SyntheticsDowntimeData" + required: + - data + type: object + SyntheticsDowntimeTags: + description: List of tags associated with a Synthetics downtime. + example: + - "team:backend" + - "env:prod" + items: + description: A tag. + type: string + type: array + SyntheticsDowntimeTestIds: + description: List of Synthetics test public IDs associated with a downtime. + example: + - abc-def-123 + - xyz-uvw-456 + items: + description: A Synthetics test public ID. + type: string + type: array + SyntheticsDowntimeTimeSlotDate: + description: A specific date and time used to define the start or end of a Synthetics downtime time slot. + properties: + day: + description: The day component of the date (1-31). + example: 15 + format: int64 + type: integer + hour: + description: The hour component of the time (0-23). + example: 10 + format: int64 + type: integer + minute: + description: The minute component of the time (0-59). + example: 30 + format: int64 + type: integer + month: + description: The month component of the date (1-12). + example: 1 + format: int64 + type: integer + year: + description: The year component of the date. + example: 2024 + format: int64 + type: integer + required: + - year + - month + - day + - hour + - minute + type: object + SyntheticsDowntimeTimeSlotRecurrenceRequest: + description: Recurrence settings for a Synthetics downtime time slot. + properties: + end: + $ref: "#/components/schemas/SyntheticsDowntimeTimeSlotDate" + frequency: + $ref: "#/components/schemas/SyntheticsDowntimeFrequency" + interval: + description: The interval between recurrences, relative to the frequency. + example: 1 + format: int64 + type: integer + weekdays: + $ref: "#/components/schemas/SyntheticsDowntimeWeekdays" + required: + - frequency + type: object + SyntheticsDowntimeTimeSlotRecurrenceResponse: + description: Recurrence settings returned in a Synthetics downtime time slot response. + properties: + frequency: + $ref: "#/components/schemas/SyntheticsDowntimeFrequency" + interval: + description: The interval between recurrences, relative to the frequency. + example: 1 + format: int64 + type: integer + until: + $ref: "#/components/schemas/SyntheticsDowntimeTimeSlotDate" + weekdays: + $ref: "#/components/schemas/SyntheticsDowntimeWeekdays" + required: + - frequency + - interval + - weekdays + type: object + SyntheticsDowntimeTimeSlotRequest: + description: A time slot for a Synthetics downtime create or update request. + properties: + duration: + description: The duration of the time slot in seconds, between 60 and 604800. + example: 3600 + format: int64 + type: integer + name: + description: An optional label for the time slot. + example: Weekly maintenance window + type: string + recurrence: + $ref: "#/components/schemas/SyntheticsDowntimeTimeSlotRecurrenceRequest" + start: + $ref: "#/components/schemas/SyntheticsDowntimeTimeSlotDate" + timezone: + description: The IANA timezone name for the time slot. + example: Europe/Paris + type: string + required: + - start + - timezone + - duration + type: object + SyntheticsDowntimeTimeSlotRequests: + description: List of time slots for a Synthetics downtime create or update request. + example: + - duration: 3600 + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + items: + $ref: "#/components/schemas/SyntheticsDowntimeTimeSlotRequest" + type: array + SyntheticsDowntimeTimeSlotResponse: + description: A time slot returned in a Synthetics downtime response. + properties: + duration: + description: The duration of the time slot in seconds. + example: 3600 + format: int64 + type: integer + id: + description: The unique identifier of the time slot. + example: "00000000-0000-0000-0000-000000000002" + type: string + name: + description: The label for the time slot. + example: Weekly maintenance window + type: string + recurrence: + $ref: "#/components/schemas/SyntheticsDowntimeTimeSlotRecurrenceResponse" + start: + $ref: "#/components/schemas/SyntheticsDowntimeTimeSlotDate" + timezone: + description: The IANA timezone name for the time slot. + example: Europe/Paris + type: string + required: + - id + - start + - timezone + - duration + type: object + SyntheticsDowntimeTimeSlotResponses: + description: List of time slots in a Synthetics downtime response. + example: + - duration: 3600 + id: "00000000-0000-0000-0000-000000000002" + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + items: + $ref: "#/components/schemas/SyntheticsDowntimeTimeSlotResponse" + type: array + SyntheticsDowntimeWeekday: + description: A day of the week for a Synthetics downtime recurrence. + enum: + - MO + - TU + - WE + - TH + - FR + - SA + - SU + example: MO + type: string + x-enum-varnames: + - MONDAY + - TUESDAY + - WEDNESDAY + - THURSDAY + - FRIDAY + - SATURDAY + - SUNDAY + SyntheticsDowntimeWeekdays: + description: Days of the week for a Synthetics downtime recurrence schedule. + example: + - MO + - WE + - FR + items: + $ref: "#/components/schemas/SyntheticsDowntimeWeekday" + type: array + SyntheticsDowntimesResponse: + description: Response containing a list of Synthetics downtimes. + properties: + data: + $ref: "#/components/schemas/SyntheticsDowntimeDataList" + required: + - data + type: object SyntheticsFastTestResult: description: |- Fast test result response. Returns `null` if the result is not yet available @@ -127129,6 +127539,545 @@ paths: operator: OR permissions: - synthetics_read + /api/v2/synthetics/downtimes: + get: + description: Get a list of all Synthetics downtimes for your organization. + operationId: ListSyntheticsDowntimes + parameters: + - description: Comma-separated list of Synthetics test public IDs to filter downtimes by. + in: query + name: filter[test_ids] + required: false + schema: + example: abc-def-123,xyz-uvw-456 + type: string + - description: If set to `true`, return only downtimes that are currently active. + in: query + name: filter[active] + required: false + schema: + example: "true" + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + createdAt: "2024-01-15T10:30:00Z" + createdBy: "00000000-0000-0000-0000-000000000003" + createdByName: Jane Doe + description: Scheduled weekly maintenance window. + isEnabled: true + name: Weekly maintenance + tags: [] + testIds: + - abc-def-123 + timeSlots: + - duration: 3600 + id: "00000000-0000-0000-0000-000000000002" + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + updatedAt: "2024-01-15T10:30:00Z" + updatedBy: "00000000-0000-0000-0000-000000000003" + updatedByName: Jane Doe + id: "00000000-0000-0000-0000-000000000001" + type: downtime + schema: + $ref: "#/components/schemas/SyntheticsDowntimesResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List Synthetics downtimes + tags: + - Synthetics + x-permission: + operator: AND + permissions: + - synthetics_read + post: + description: Create a new Synthetics downtime. + operationId: CreateSyntheticsDowntime + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + isEnabled: true + name: Weekly maintenance + testIds: + - abc-def-123 + timeSlots: + - duration: 3600 + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + type: downtime + schema: + $ref: "#/components/schemas/SyntheticsDowntimeRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + createdAt: "2024-01-15T10:30:00Z" + createdBy: "00000000-0000-0000-0000-000000000003" + createdByName: Jane Doe + description: Scheduled weekly maintenance window. + isEnabled: true + name: Weekly maintenance + tags: [] + testIds: + - abc-def-123 + timeSlots: + - duration: 3600 + id: "00000000-0000-0000-0000-000000000002" + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + updatedAt: "2024-01-15T10:30:00Z" + updatedBy: "00000000-0000-0000-0000-000000000003" + updatedByName: Jane Doe + id: "00000000-0000-0000-0000-000000000001" + type: downtime + schema: + $ref: "#/components/schemas/SyntheticsDowntimeResponse" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Create a Synthetics downtime + tags: + - Synthetics + x-permission: + operator: AND + permissions: + - synthetics_write + /api/v2/synthetics/downtimes/{downtime_id}: + delete: + description: Delete a Synthetics downtime by its ID. + operationId: DeleteSyntheticsDowntime + parameters: + - description: The ID of the downtime to delete. + in: path + name: downtime_id + required: true + schema: + example: "00000000-0000-0000-0000-000000000001" + type: string + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete a Synthetics downtime + tags: + - Synthetics + x-permission: + operator: AND + permissions: + - synthetics_write + get: + description: Get a Synthetics downtime by its ID. + operationId: GetSyntheticsDowntime + parameters: + - description: The ID of the downtime to retrieve. + in: path + name: downtime_id + required: true + schema: + example: "00000000-0000-0000-0000-000000000001" + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + createdAt: "2024-01-15T10:30:00Z" + createdBy: "00000000-0000-0000-0000-000000000003" + createdByName: Jane Doe + description: Scheduled weekly maintenance window. + isEnabled: true + name: Weekly maintenance + tags: [] + testIds: + - abc-def-123 + timeSlots: + - duration: 3600 + id: "00000000-0000-0000-0000-000000000002" + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + updatedAt: "2024-01-15T10:30:00Z" + updatedBy: "00000000-0000-0000-0000-000000000003" + updatedByName: Jane Doe + id: "00000000-0000-0000-0000-000000000001" + type: downtime + schema: + $ref: "#/components/schemas/SyntheticsDowntimeResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get a Synthetics downtime + tags: + - Synthetics + x-permission: + operator: AND + permissions: + - synthetics_read + put: + description: Update a Synthetics downtime by its ID. + operationId: UpdateSyntheticsDowntime + parameters: + - description: The ID of the downtime to update. + in: path + name: downtime_id + required: true + schema: + example: "00000000-0000-0000-0000-000000000001" + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + isEnabled: true + name: Weekly maintenance + testIds: + - abc-def-123 + timeSlots: + - duration: 3600 + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + type: downtime + schema: + $ref: "#/components/schemas/SyntheticsDowntimeRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + createdAt: "2024-01-15T10:30:00Z" + createdBy: "00000000-0000-0000-0000-000000000003" + createdByName: Jane Doe + description: Scheduled weekly maintenance window. + isEnabled: true + name: Weekly maintenance + tags: [] + testIds: + - abc-def-123 + timeSlots: + - duration: 3600 + id: "00000000-0000-0000-0000-000000000002" + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + updatedAt: "2024-01-15T10:30:00Z" + updatedBy: "00000000-0000-0000-0000-000000000003" + updatedByName: Jane Doe + id: "00000000-0000-0000-0000-000000000001" + type: downtime + schema: + $ref: "#/components/schemas/SyntheticsDowntimeResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Update a Synthetics downtime + tags: + - Synthetics + x-permission: + operator: AND + permissions: + - synthetics_write + /api/v2/synthetics/downtimes/{downtime_id}/tests/{test_id}: + delete: + description: Disassociate a Synthetics test from a downtime. + operationId: RemoveTestFromSyntheticsDowntime + parameters: + - description: The ID of the downtime. + in: path + name: downtime_id + required: true + schema: + example: "00000000-0000-0000-0000-000000000001" + type: string + - description: The public ID of the Synthetics test to disassociate from the downtime. + in: path + name: test_id + required: true + schema: + example: abc-def-123 + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + createdAt: "2024-01-15T10:30:00Z" + createdBy: "00000000-0000-0000-0000-000000000003" + createdByName: Jane Doe + description: Scheduled weekly maintenance window. + isEnabled: true + name: Weekly maintenance + tags: [] + testIds: + - abc-def-123 + timeSlots: + - duration: 3600 + id: "00000000-0000-0000-0000-000000000002" + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + updatedAt: "2024-01-15T10:30:00Z" + updatedBy: "00000000-0000-0000-0000-000000000003" + updatedByName: Jane Doe + id: "00000000-0000-0000-0000-000000000001" + type: downtime + schema: + $ref: "#/components/schemas/SyntheticsDowntimeResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Remove a test from a Synthetics downtime + tags: + - Synthetics + x-permission: + operator: AND + permissions: + - synthetics_write + put: + description: Associate a Synthetics test with a downtime. + operationId: AddTestToSyntheticsDowntime + parameters: + - description: The ID of the downtime. + in: path + name: downtime_id + required: true + schema: + example: "00000000-0000-0000-0000-000000000001" + type: string + - description: The public ID of the Synthetics test to associate with the downtime. + in: path + name: test_id + required: true + schema: + example: abc-def-123 + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + createdAt: "2024-01-15T10:30:00Z" + createdBy: "00000000-0000-0000-0000-000000000003" + createdByName: Jane Doe + description: Scheduled weekly maintenance window. + isEnabled: true + name: Weekly maintenance + tags: [] + testIds: + - abc-def-123 + timeSlots: + - duration: 3600 + id: "00000000-0000-0000-0000-000000000002" + start: + day: 15 + hour: 10 + minute: 30 + month: 1 + year: 2024 + timezone: Europe/Paris + updatedAt: "2024-01-15T10:30:00Z" + updatedBy: "00000000-0000-0000-0000-000000000003" + updatedByName: Jane Doe + id: "00000000-0000-0000-0000-000000000001" + type: downtime + schema: + $ref: "#/components/schemas/SyntheticsDowntimeResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Add a test to a Synthetics downtime + tags: + - Synthetics + x-permission: + operator: AND + permissions: + - synthetics_write /api/v2/synthetics/settings/on_demand_concurrency_cap: get: description: Get the on-demand concurrency cap. diff --git a/api/datadogV2/api_synthetics.go b/api/datadogV2/api_synthetics.go index 6413717470c..491ead1e289 100644 --- a/api/datadogV2/api_synthetics.go +++ b/api/datadogV2/api_synthetics.go @@ -88,6 +88,94 @@ func (a *SyntheticsApi) AbortTestFileMultipartUpload(ctx _context.Context, publi return localVarHTTPResponse, nil } +// AddTestToSyntheticsDowntime Add a test to a Synthetics downtime. +// Associate a Synthetics test with a downtime. +func (a *SyntheticsApi) AddTestToSyntheticsDowntime(ctx _context.Context, downtimeId string, testId string) (SyntheticsDowntimeResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue SyntheticsDowntimeResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.AddTestToSyntheticsDowntime") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/downtimes/{downtime_id}/tests/{test_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{downtime_id}", _neturl.PathEscape(datadog.ParameterToString(downtimeId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{test_id}", _neturl.PathEscape(datadog.ParameterToString(testId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // CompleteTestFileMultipartUpload Complete a multipart upload of a test file. // Complete a multipart file upload for a Synthetic test. Call this endpoint after all parts // have been uploaded using the presigned URLs obtained from the multipart presigned URLs endpoint. @@ -160,6 +248,95 @@ func (a *SyntheticsApi) CompleteTestFileMultipartUpload(ctx _context.Context, pu return localVarHTTPResponse, nil } +// CreateSyntheticsDowntime Create a Synthetics downtime. +// Create a new Synthetics downtime. +func (a *SyntheticsApi) CreateSyntheticsDowntime(ctx _context.Context, body SyntheticsDowntimeRequest) (SyntheticsDowntimeResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue SyntheticsDowntimeResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.CreateSyntheticsDowntime") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/downtimes" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // CreateSyntheticsNetworkTest Create a Network Path test. func (a *SyntheticsApi) CreateSyntheticsNetworkTest(ctx _context.Context, body SyntheticsNetworkTestEditRequest) (SyntheticsNetworkTestResponse, *_nethttp.Response, error) { @@ -320,6 +497,83 @@ func (a *SyntheticsApi) CreateSyntheticsSuite(ctx _context.Context, body SuiteCr return localVarReturnValue, localVarHTTPResponse, nil } +// DeleteSyntheticsDowntime Delete a Synthetics downtime. +// Delete a Synthetics downtime by its ID. +func (a *SyntheticsApi) DeleteSyntheticsDowntime(ctx _context.Context, downtimeId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.DeleteSyntheticsDowntime") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/downtimes/{downtime_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{downtime_id}", _neturl.PathEscape(datadog.ParameterToString(downtimeId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return 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 == 403 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if 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 +} + // DeleteSyntheticsSuites Bulk delete suites. func (a *SyntheticsApi) DeleteSyntheticsSuites(ctx _context.Context, body DeletedSuitesRequestDeleteRequest) (DeletedSuitesResponse, *_nethttp.Response, error) { @@ -890,7 +1144,94 @@ func (a *SyntheticsApi) GetSyntheticsBrowserTestResult(ctx _context.Context, pub ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 400 || 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 +} + +// GetSyntheticsDowntime Get a Synthetics downtime. +// Get a Synthetics downtime by its ID. +func (a *SyntheticsApi) GetSyntheticsDowntime(ctx _context.Context, downtimeId string) (SyntheticsDowntimeResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue SyntheticsDowntimeResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.GetSyntheticsDowntime") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/downtimes/{downtime_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{downtime_id}", _neturl.PathEscape(datadog.ParameterToString(downtimeId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { @@ -1795,6 +2136,130 @@ func (a *SyntheticsApi) ListSyntheticsBrowserTestLatestResults(ctx _context.Cont return localVarReturnValue, localVarHTTPResponse, nil } +// ListSyntheticsDowntimesOptionalParameters holds optional parameters for ListSyntheticsDowntimes. +type ListSyntheticsDowntimesOptionalParameters struct { + FilterTestIds *string + FilterActive *string +} + +// NewListSyntheticsDowntimesOptionalParameters creates an empty struct for parameters. +func NewListSyntheticsDowntimesOptionalParameters() *ListSyntheticsDowntimesOptionalParameters { + this := ListSyntheticsDowntimesOptionalParameters{} + return &this +} + +// WithFilterTestIds sets the corresponding parameter name and returns the struct. +func (r *ListSyntheticsDowntimesOptionalParameters) WithFilterTestIds(filterTestIds string) *ListSyntheticsDowntimesOptionalParameters { + r.FilterTestIds = &filterTestIds + return r +} + +// WithFilterActive sets the corresponding parameter name and returns the struct. +func (r *ListSyntheticsDowntimesOptionalParameters) WithFilterActive(filterActive string) *ListSyntheticsDowntimesOptionalParameters { + r.FilterActive = &filterActive + return r +} + +// ListSyntheticsDowntimes List Synthetics downtimes. +// Get a list of all Synthetics downtimes for your organization. +func (a *SyntheticsApi) ListSyntheticsDowntimes(ctx _context.Context, o ...ListSyntheticsDowntimesOptionalParameters) (SyntheticsDowntimesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue SyntheticsDowntimesResponse + optionalParams ListSyntheticsDowntimesOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListSyntheticsDowntimesOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.ListSyntheticsDowntimes") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/downtimes" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.FilterTestIds != nil { + localVarQueryParams.Add("filter[test_ids]", datadog.ParameterToString(*optionalParams.FilterTestIds, "")) + } + if optionalParams.FilterActive != nil { + localVarQueryParams.Add("filter[active]", datadog.ParameterToString(*optionalParams.FilterActive, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // ListSyntheticsTestLatestResultsOptionalParameters holds optional parameters for ListSyntheticsTestLatestResults. type ListSyntheticsTestLatestResultsOptionalParameters struct { FromTs *int64 @@ -2337,6 +2802,94 @@ func (a *SyntheticsApi) PollSyntheticsTestResults(ctx _context.Context, resultId return localVarReturnValue, localVarHTTPResponse, nil } +// RemoveTestFromSyntheticsDowntime Remove a test from a Synthetics downtime. +// Disassociate a Synthetics test from a downtime. +func (a *SyntheticsApi) RemoveTestFromSyntheticsDowntime(ctx _context.Context, downtimeId string, testId string) (SyntheticsDowntimeResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarReturnValue SyntheticsDowntimeResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.RemoveTestFromSyntheticsDowntime") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/downtimes/{downtime_id}/tests/{test_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{downtime_id}", _neturl.PathEscape(datadog.ParameterToString(downtimeId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{test_id}", _neturl.PathEscape(datadog.ParameterToString(testId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // SearchSuitesOptionalParameters holds optional parameters for SearchSuites. type SearchSuitesOptionalParameters struct { Query *string @@ -2562,6 +3115,96 @@ func (a *SyntheticsApi) SetOnDemandConcurrencyCap(ctx _context.Context, body OnD return localVarReturnValue, localVarHTTPResponse, nil } +// UpdateSyntheticsDowntime Update a Synthetics downtime. +// Update a Synthetics downtime by its ID. +func (a *SyntheticsApi) UpdateSyntheticsDowntime(ctx _context.Context, downtimeId string, body SyntheticsDowntimeRequest) (SyntheticsDowntimeResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue SyntheticsDowntimeResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.UpdateSyntheticsDowntime") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/downtimes/{downtime_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{downtime_id}", _neturl.PathEscape(datadog.ParameterToString(downtimeId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // UpdateSyntheticsNetworkTest Edit a Network Path test. func (a *SyntheticsApi) UpdateSyntheticsNetworkTest(ctx _context.Context, publicId string, body SyntheticsNetworkTestEditRequest) (SyntheticsNetworkTestResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 337034c75e8..603812f6338 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -918,9 +918,12 @@ // - [StatusPagesApi.UpdateMaintenance] // - [StatusPagesApi.UpdateStatusPage] // - [SyntheticsApi.AbortTestFileMultipartUpload] +// - [SyntheticsApi.AddTestToSyntheticsDowntime] // - [SyntheticsApi.CompleteTestFileMultipartUpload] +// - [SyntheticsApi.CreateSyntheticsDowntime] // - [SyntheticsApi.CreateSyntheticsNetworkTest] // - [SyntheticsApi.CreateSyntheticsSuite] +// - [SyntheticsApi.DeleteSyntheticsDowntime] // - [SyntheticsApi.DeleteSyntheticsSuites] // - [SyntheticsApi.DeleteSyntheticsTests] // - [SyntheticsApi.EditSyntheticsSuite] @@ -928,6 +931,7 @@ // - [SyntheticsApi.GetApiMultistepSubtests] // - [SyntheticsApi.GetOnDemandConcurrencyCap] // - [SyntheticsApi.GetSyntheticsBrowserTestResult] +// - [SyntheticsApi.GetSyntheticsDowntime] // - [SyntheticsApi.GetSyntheticsFastTestResult] // - [SyntheticsApi.GetSyntheticsNetworkTest] // - [SyntheticsApi.GetSyntheticsSuite] @@ -937,13 +941,16 @@ // - [SyntheticsApi.GetTestFileMultipartPresignedUrls] // - [SyntheticsApi.GetTestParentSuites] // - [SyntheticsApi.ListSyntheticsBrowserTestLatestResults] +// - [SyntheticsApi.ListSyntheticsDowntimes] // - [SyntheticsApi.ListSyntheticsTestLatestResults] // - [SyntheticsApi.ListSyntheticsTestVersions] // - [SyntheticsApi.PatchGlobalVariable] // - [SyntheticsApi.PatchTestSuite] // - [SyntheticsApi.PollSyntheticsTestResults] +// - [SyntheticsApi.RemoveTestFromSyntheticsDowntime] // - [SyntheticsApi.SearchSuites] // - [SyntheticsApi.SetOnDemandConcurrencyCap] +// - [SyntheticsApi.UpdateSyntheticsDowntime] // - [SyntheticsApi.UpdateSyntheticsNetworkTest] // - [TeamsApi.AddMemberTeam] // - [TeamsApi.AddTeamHierarchyLink] diff --git a/api/datadogV2/model_synthetics_downtime_data.go b/api/datadogV2/model_synthetics_downtime_data.go new file mode 100644 index 00000000000..c91b22591fe --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_data.go @@ -0,0 +1,178 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsDowntimeData A Synthetics downtime object. +type SyntheticsDowntimeData struct { + // Attributes of a Synthetics downtime response object. + Attributes SyntheticsDowntimeDataAttributesResponse `json:"attributes"` + // The unique identifier of the downtime. + Id string `json:"id"` + // The resource type for a Synthetics downtime. + Type SyntheticsDowntimeResourceType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsDowntimeData instantiates a new SyntheticsDowntimeData 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 NewSyntheticsDowntimeData(attributes SyntheticsDowntimeDataAttributesResponse, id string, typeVar SyntheticsDowntimeResourceType) *SyntheticsDowntimeData { + this := SyntheticsDowntimeData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewSyntheticsDowntimeDataWithDefaults instantiates a new SyntheticsDowntimeData 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 NewSyntheticsDowntimeDataWithDefaults() *SyntheticsDowntimeData { + this := SyntheticsDowntimeData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *SyntheticsDowntimeData) GetAttributes() SyntheticsDowntimeDataAttributesResponse { + if o == nil { + var ret SyntheticsDowntimeDataAttributesResponse + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeData) GetAttributesOk() (*SyntheticsDowntimeDataAttributesResponse, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *SyntheticsDowntimeData) SetAttributes(v SyntheticsDowntimeDataAttributesResponse) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *SyntheticsDowntimeData) 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 *SyntheticsDowntimeData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *SyntheticsDowntimeData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *SyntheticsDowntimeData) GetType() SyntheticsDowntimeResourceType { + if o == nil { + var ret SyntheticsDowntimeResourceType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeData) GetTypeOk() (*SyntheticsDowntimeResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SyntheticsDowntimeData) SetType(v SyntheticsDowntimeResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SyntheticsDowntimeDataAttributesResponse `json:"attributes"` + Id *string `json:"id"` + Type *SyntheticsDowntimeResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_data_attributes_request.go b/api/datadogV2/model_synthetics_downtime_data_attributes_request.go new file mode 100644 index 00000000000..d3733320bfc --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_data_attributes_request.go @@ -0,0 +1,267 @@ +// 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" +) + +// SyntheticsDowntimeDataAttributesRequest Attributes for creating or updating a Synthetics downtime. +type SyntheticsDowntimeDataAttributesRequest struct { + // An optional description of the downtime. + Description *string `json:"description,omitempty"` + // Whether the downtime is enabled. + IsEnabled bool `json:"isEnabled"` + // The name of the downtime. + Name string `json:"name"` + // List of tags associated with a Synthetics downtime. + Tags []string `json:"tags,omitempty"` + // List of Synthetics test public IDs associated with a downtime. + TestIds []string `json:"testIds"` + // List of time slots for a Synthetics downtime create or update request. + TimeSlots []SyntheticsDowntimeTimeSlotRequest `json:"timeSlots"` + // 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:"-"` +} + +// NewSyntheticsDowntimeDataAttributesRequest instantiates a new SyntheticsDowntimeDataAttributesRequest 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 NewSyntheticsDowntimeDataAttributesRequest(isEnabled bool, name string, testIds []string, timeSlots []SyntheticsDowntimeTimeSlotRequest) *SyntheticsDowntimeDataAttributesRequest { + this := SyntheticsDowntimeDataAttributesRequest{} + this.IsEnabled = isEnabled + this.Name = name + this.TestIds = testIds + this.TimeSlots = timeSlots + return &this +} + +// NewSyntheticsDowntimeDataAttributesRequestWithDefaults instantiates a new SyntheticsDowntimeDataAttributesRequest 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 NewSyntheticsDowntimeDataAttributesRequestWithDefaults() *SyntheticsDowntimeDataAttributesRequest { + this := SyntheticsDowntimeDataAttributesRequest{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *SyntheticsDowntimeDataAttributesRequest) GetDescription() string { + if o == nil || o.Description == nil { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesRequest) GetDescriptionOk() (*string, bool) { + if o == nil || o.Description == nil { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *SyntheticsDowntimeDataAttributesRequest) HasDescription() bool { + return o != nil && o.Description != nil +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *SyntheticsDowntimeDataAttributesRequest) SetDescription(v string) { + o.Description = &v +} + +// GetIsEnabled returns the IsEnabled field value. +func (o *SyntheticsDowntimeDataAttributesRequest) GetIsEnabled() bool { + if o == nil { + var ret bool + return ret + } + return o.IsEnabled +} + +// GetIsEnabledOk returns a tuple with the IsEnabled field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesRequest) GetIsEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.IsEnabled, true +} + +// SetIsEnabled sets field value. +func (o *SyntheticsDowntimeDataAttributesRequest) SetIsEnabled(v bool) { + o.IsEnabled = v +} + +// GetName returns the Name field value. +func (o *SyntheticsDowntimeDataAttributesRequest) 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 *SyntheticsDowntimeDataAttributesRequest) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *SyntheticsDowntimeDataAttributesRequest) SetName(v string) { + o.Name = v +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *SyntheticsDowntimeDataAttributesRequest) 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 *SyntheticsDowntimeDataAttributesRequest) 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 *SyntheticsDowntimeDataAttributesRequest) 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 *SyntheticsDowntimeDataAttributesRequest) SetTags(v []string) { + o.Tags = v +} + +// GetTestIds returns the TestIds field value. +func (o *SyntheticsDowntimeDataAttributesRequest) GetTestIds() []string { + if o == nil { + var ret []string + return ret + } + return o.TestIds +} + +// GetTestIdsOk returns a tuple with the TestIds field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesRequest) GetTestIdsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.TestIds, true +} + +// SetTestIds sets field value. +func (o *SyntheticsDowntimeDataAttributesRequest) SetTestIds(v []string) { + o.TestIds = v +} + +// GetTimeSlots returns the TimeSlots field value. +func (o *SyntheticsDowntimeDataAttributesRequest) GetTimeSlots() []SyntheticsDowntimeTimeSlotRequest { + if o == nil { + var ret []SyntheticsDowntimeTimeSlotRequest + return ret + } + return o.TimeSlots +} + +// GetTimeSlotsOk returns a tuple with the TimeSlots field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesRequest) GetTimeSlotsOk() (*[]SyntheticsDowntimeTimeSlotRequest, bool) { + if o == nil { + return nil, false + } + return &o.TimeSlots, true +} + +// SetTimeSlots sets field value. +func (o *SyntheticsDowntimeDataAttributesRequest) SetTimeSlots(v []SyntheticsDowntimeTimeSlotRequest) { + o.TimeSlots = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeDataAttributesRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + toSerialize["isEnabled"] = o.IsEnabled + toSerialize["name"] = o.Name + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + toSerialize["testIds"] = o.TestIds + toSerialize["timeSlots"] = o.TimeSlots + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeDataAttributesRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description,omitempty"` + IsEnabled *bool `json:"isEnabled"` + Name *string `json:"name"` + Tags []string `json:"tags,omitempty"` + TestIds *[]string `json:"testIds"` + TimeSlots *[]SyntheticsDowntimeTimeSlotRequest `json:"timeSlots"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.IsEnabled == nil { + return fmt.Errorf("required field isEnabled missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.TestIds == nil { + return fmt.Errorf("required field testIds missing") + } + if all.TimeSlots == nil { + return fmt.Errorf("required field timeSlots missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "isEnabled", "name", "tags", "testIds", "timeSlots"}) + } else { + return err + } + o.Description = all.Description + o.IsEnabled = *all.IsEnabled + o.Name = *all.Name + o.Tags = all.Tags + o.TestIds = *all.TestIds + o.TimeSlots = *all.TimeSlots + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_data_attributes_response.go b/api/datadogV2/model_synthetics_downtime_data_attributes_response.go new file mode 100644 index 00000000000..af30e40f3bb --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_data_attributes_response.go @@ -0,0 +1,462 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsDowntimeDataAttributesResponse Attributes of a Synthetics downtime response object. +type SyntheticsDowntimeDataAttributesResponse struct { + // The timestamp when the downtime was created. + CreatedAt time.Time `json:"createdAt"` + // The UUID of the user who created the downtime. + CreatedBy string `json:"createdBy"` + // The display name of the user who created the downtime. + CreatedByName string `json:"createdByName"` + // The description of the downtime. + Description string `json:"description"` + // Whether the downtime is enabled. + IsEnabled bool `json:"isEnabled"` + // The name of the downtime. + Name string `json:"name"` + // List of tags associated with a Synthetics downtime. + Tags []string `json:"tags"` + // List of Synthetics test public IDs associated with a downtime. + TestIds []string `json:"testIds"` + // List of time slots in a Synthetics downtime response. + TimeSlots []SyntheticsDowntimeTimeSlotResponse `json:"timeSlots"` + // The timestamp when the downtime was last updated. + UpdatedAt time.Time `json:"updatedAt"` + // The UUID of the user who last updated the downtime. + UpdatedBy string `json:"updatedBy"` + // The display name of the user who last updated the downtime. + UpdatedByName string `json:"updatedByName"` + // 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:"-"` +} + +// NewSyntheticsDowntimeDataAttributesResponse instantiates a new SyntheticsDowntimeDataAttributesResponse 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 NewSyntheticsDowntimeDataAttributesResponse(createdAt time.Time, createdBy string, createdByName string, description string, isEnabled bool, name string, tags []string, testIds []string, timeSlots []SyntheticsDowntimeTimeSlotResponse, updatedAt time.Time, updatedBy string, updatedByName string) *SyntheticsDowntimeDataAttributesResponse { + this := SyntheticsDowntimeDataAttributesResponse{} + this.CreatedAt = createdAt + this.CreatedBy = createdBy + this.CreatedByName = createdByName + this.Description = description + this.IsEnabled = isEnabled + this.Name = name + this.Tags = tags + this.TestIds = testIds + this.TimeSlots = timeSlots + this.UpdatedAt = updatedAt + this.UpdatedBy = updatedBy + this.UpdatedByName = updatedByName + return &this +} + +// NewSyntheticsDowntimeDataAttributesResponseWithDefaults instantiates a new SyntheticsDowntimeDataAttributesResponse 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 NewSyntheticsDowntimeDataAttributesResponseWithDefaults() *SyntheticsDowntimeDataAttributesResponse { + this := SyntheticsDowntimeDataAttributesResponse{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetCreatedBy returns the CreatedBy field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetCreatedBy() string { + if o == nil { + var ret string + return ret + } + return o.CreatedBy +} + +// GetCreatedByOk returns a tuple with the CreatedBy field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetCreatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.CreatedBy, true +} + +// SetCreatedBy sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetCreatedBy(v string) { + o.CreatedBy = v +} + +// GetCreatedByName returns the CreatedByName field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetCreatedByName() string { + if o == nil { + var ret string + return ret + } + return o.CreatedByName +} + +// GetCreatedByNameOk returns a tuple with the CreatedByName field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetCreatedByNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.CreatedByName, true +} + +// SetCreatedByName sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetCreatedByName(v string) { + o.CreatedByName = v +} + +// GetDescription returns the Description field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetDescription(v string) { + o.Description = v +} + +// GetIsEnabled returns the IsEnabled field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetIsEnabled() bool { + if o == nil { + var ret bool + return ret + } + return o.IsEnabled +} + +// GetIsEnabledOk returns a tuple with the IsEnabled field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetIsEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.IsEnabled, true +} + +// SetIsEnabled sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetIsEnabled(v bool) { + o.IsEnabled = v +} + +// GetName returns the Name field value. +func (o *SyntheticsDowntimeDataAttributesResponse) 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 *SyntheticsDowntimeDataAttributesResponse) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetName(v string) { + o.Name = v +} + +// GetTags returns the Tags field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetTags() []string { + if o == nil { + var ret []string + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetTagsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Tags, true +} + +// SetTags sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetTags(v []string) { + o.Tags = v +} + +// GetTestIds returns the TestIds field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetTestIds() []string { + if o == nil { + var ret []string + return ret + } + return o.TestIds +} + +// GetTestIdsOk returns a tuple with the TestIds field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetTestIdsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.TestIds, true +} + +// SetTestIds sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetTestIds(v []string) { + o.TestIds = v +} + +// GetTimeSlots returns the TimeSlots field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetTimeSlots() []SyntheticsDowntimeTimeSlotResponse { + if o == nil { + var ret []SyntheticsDowntimeTimeSlotResponse + return ret + } + return o.TimeSlots +} + +// GetTimeSlotsOk returns a tuple with the TimeSlots field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetTimeSlotsOk() (*[]SyntheticsDowntimeTimeSlotResponse, bool) { + if o == nil { + return nil, false + } + return &o.TimeSlots, true +} + +// SetTimeSlots sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetTimeSlots(v []SyntheticsDowntimeTimeSlotResponse) { + o.TimeSlots = v +} + +// GetUpdatedAt returns the UpdatedAt field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +// GetUpdatedBy returns the UpdatedBy field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetUpdatedBy() string { + if o == nil { + var ret string + return ret + } + return o.UpdatedBy +} + +// GetUpdatedByOk returns a tuple with the UpdatedBy field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetUpdatedByOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedBy, true +} + +// SetUpdatedBy sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetUpdatedBy(v string) { + o.UpdatedBy = v +} + +// GetUpdatedByName returns the UpdatedByName field value. +func (o *SyntheticsDowntimeDataAttributesResponse) GetUpdatedByName() string { + if o == nil { + var ret string + return ret + } + return o.UpdatedByName +} + +// GetUpdatedByNameOk returns a tuple with the UpdatedByName field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataAttributesResponse) GetUpdatedByNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedByName, true +} + +// SetUpdatedByName sets field value. +func (o *SyntheticsDowntimeDataAttributesResponse) SetUpdatedByName(v string) { + o.UpdatedByName = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeDataAttributesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["createdAt"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["createdAt"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["createdBy"] = o.CreatedBy + toSerialize["createdByName"] = o.CreatedByName + toSerialize["description"] = o.Description + toSerialize["isEnabled"] = o.IsEnabled + toSerialize["name"] = o.Name + toSerialize["tags"] = o.Tags + toSerialize["testIds"] = o.TestIds + toSerialize["timeSlots"] = o.TimeSlots + if o.UpdatedAt.Nanosecond() == 0 { + toSerialize["updatedAt"] = o.UpdatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["updatedAt"] = o.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["updatedBy"] = o.UpdatedBy + toSerialize["updatedByName"] = o.UpdatedByName + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeDataAttributesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *time.Time `json:"createdAt"` + CreatedBy *string `json:"createdBy"` + CreatedByName *string `json:"createdByName"` + Description *string `json:"description"` + IsEnabled *bool `json:"isEnabled"` + Name *string `json:"name"` + Tags *[]string `json:"tags"` + TestIds *[]string `json:"testIds"` + TimeSlots *[]SyntheticsDowntimeTimeSlotResponse `json:"timeSlots"` + UpdatedAt *time.Time `json:"updatedAt"` + UpdatedBy *string `json:"updatedBy"` + UpdatedByName *string `json:"updatedByName"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CreatedAt == nil { + return fmt.Errorf("required field createdAt missing") + } + if all.CreatedBy == nil { + return fmt.Errorf("required field createdBy missing") + } + if all.CreatedByName == nil { + return fmt.Errorf("required field createdByName missing") + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.IsEnabled == nil { + return fmt.Errorf("required field isEnabled missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Tags == nil { + return fmt.Errorf("required field tags missing") + } + if all.TestIds == nil { + return fmt.Errorf("required field testIds missing") + } + if all.TimeSlots == nil { + return fmt.Errorf("required field timeSlots missing") + } + if all.UpdatedAt == nil { + return fmt.Errorf("required field updatedAt missing") + } + if all.UpdatedBy == nil { + return fmt.Errorf("required field updatedBy missing") + } + if all.UpdatedByName == nil { + return fmt.Errorf("required field updatedByName missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"createdAt", "createdBy", "createdByName", "description", "isEnabled", "name", "tags", "testIds", "timeSlots", "updatedAt", "updatedBy", "updatedByName"}) + } else { + return err + } + o.CreatedAt = *all.CreatedAt + o.CreatedBy = *all.CreatedBy + o.CreatedByName = *all.CreatedByName + o.Description = *all.Description + o.IsEnabled = *all.IsEnabled + o.Name = *all.Name + o.Tags = *all.Tags + o.TestIds = *all.TestIds + o.TimeSlots = *all.TimeSlots + o.UpdatedAt = *all.UpdatedAt + o.UpdatedBy = *all.UpdatedBy + o.UpdatedByName = *all.UpdatedByName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_data_request.go b/api/datadogV2/model_synthetics_downtime_data_request.go new file mode 100644 index 00000000000..e30a198a6b6 --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_data_request.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsDowntimeDataRequest The data object for a Synthetics downtime create or update request. +type SyntheticsDowntimeDataRequest struct { + // Attributes for creating or updating a Synthetics downtime. + Attributes SyntheticsDowntimeDataAttributesRequest `json:"attributes"` + // The resource type for a Synthetics downtime. + Type SyntheticsDowntimeResourceType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsDowntimeDataRequest instantiates a new SyntheticsDowntimeDataRequest 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 NewSyntheticsDowntimeDataRequest(attributes SyntheticsDowntimeDataAttributesRequest, typeVar SyntheticsDowntimeResourceType) *SyntheticsDowntimeDataRequest { + this := SyntheticsDowntimeDataRequest{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewSyntheticsDowntimeDataRequestWithDefaults instantiates a new SyntheticsDowntimeDataRequest 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 NewSyntheticsDowntimeDataRequestWithDefaults() *SyntheticsDowntimeDataRequest { + this := SyntheticsDowntimeDataRequest{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *SyntheticsDowntimeDataRequest) GetAttributes() SyntheticsDowntimeDataAttributesRequest { + if o == nil { + var ret SyntheticsDowntimeDataAttributesRequest + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataRequest) GetAttributesOk() (*SyntheticsDowntimeDataAttributesRequest, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *SyntheticsDowntimeDataRequest) SetAttributes(v SyntheticsDowntimeDataAttributesRequest) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *SyntheticsDowntimeDataRequest) GetType() SyntheticsDowntimeResourceType { + if o == nil { + var ret SyntheticsDowntimeResourceType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeDataRequest) GetTypeOk() (*SyntheticsDowntimeResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SyntheticsDowntimeDataRequest) SetType(v SyntheticsDowntimeResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeDataRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeDataRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SyntheticsDowntimeDataAttributesRequest `json:"attributes"` + Type *SyntheticsDowntimeResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_frequency.go b/api/datadogV2/model_synthetics_downtime_frequency.go new file mode 100644 index 00000000000..6778cffdfed --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_frequency.go @@ -0,0 +1,70 @@ +// 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" +) + +// SyntheticsDowntimeFrequency The recurrence frequency of a Synthetics downtime time slot. +type SyntheticsDowntimeFrequency string + +// List of SyntheticsDowntimeFrequency. +const ( + SYNTHETICSDOWNTIMEFREQUENCY_DAILY SyntheticsDowntimeFrequency = "DAILY" + SYNTHETICSDOWNTIMEFREQUENCY_WEEKLY SyntheticsDowntimeFrequency = "WEEKLY" + SYNTHETICSDOWNTIMEFREQUENCY_MONTHLY SyntheticsDowntimeFrequency = "MONTHLY" + SYNTHETICSDOWNTIMEFREQUENCY_YEARLY SyntheticsDowntimeFrequency = "YEARLY" +) + +var allowedSyntheticsDowntimeFrequencyEnumValues = []SyntheticsDowntimeFrequency{ + SYNTHETICSDOWNTIMEFREQUENCY_DAILY, + SYNTHETICSDOWNTIMEFREQUENCY_WEEKLY, + SYNTHETICSDOWNTIMEFREQUENCY_MONTHLY, + SYNTHETICSDOWNTIMEFREQUENCY_YEARLY, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SyntheticsDowntimeFrequency) GetAllowedValues() []SyntheticsDowntimeFrequency { + return allowedSyntheticsDowntimeFrequencyEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SyntheticsDowntimeFrequency) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SyntheticsDowntimeFrequency(value) + return nil +} + +// NewSyntheticsDowntimeFrequencyFromValue returns a pointer to a valid SyntheticsDowntimeFrequency +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSyntheticsDowntimeFrequencyFromValue(v string) (*SyntheticsDowntimeFrequency, error) { + ev := SyntheticsDowntimeFrequency(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SyntheticsDowntimeFrequency: valid values are %v", v, allowedSyntheticsDowntimeFrequencyEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SyntheticsDowntimeFrequency) IsValid() bool { + for _, existing := range allowedSyntheticsDowntimeFrequencyEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SyntheticsDowntimeFrequency value. +func (v SyntheticsDowntimeFrequency) Ptr() *SyntheticsDowntimeFrequency { + return &v +} diff --git a/api/datadogV2/model_synthetics_downtime_request.go b/api/datadogV2/model_synthetics_downtime_request.go new file mode 100644 index 00000000000..3a6910b9d14 --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsDowntimeRequest Request body for creating or updating a Synthetics downtime. +type SyntheticsDowntimeRequest struct { + // The data object for a Synthetics downtime create or update request. + Data SyntheticsDowntimeDataRequest `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsDowntimeRequest instantiates a new SyntheticsDowntimeRequest 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 NewSyntheticsDowntimeRequest(data SyntheticsDowntimeDataRequest) *SyntheticsDowntimeRequest { + this := SyntheticsDowntimeRequest{} + this.Data = data + return &this +} + +// NewSyntheticsDowntimeRequestWithDefaults instantiates a new SyntheticsDowntimeRequest 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 NewSyntheticsDowntimeRequestWithDefaults() *SyntheticsDowntimeRequest { + this := SyntheticsDowntimeRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *SyntheticsDowntimeRequest) GetData() SyntheticsDowntimeDataRequest { + if o == nil { + var ret SyntheticsDowntimeDataRequest + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeRequest) GetDataOk() (*SyntheticsDowntimeDataRequest, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *SyntheticsDowntimeRequest) SetData(v SyntheticsDowntimeDataRequest) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *SyntheticsDowntimeDataRequest `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_resource_type.go b/api/datadogV2/model_synthetics_downtime_resource_type.go new file mode 100644 index 00000000000..42e5eb57947 --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_resource_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" +) + +// SyntheticsDowntimeResourceType The resource type for a Synthetics downtime. +type SyntheticsDowntimeResourceType string + +// List of SyntheticsDowntimeResourceType. +const ( + SYNTHETICSDOWNTIMERESOURCETYPE_DOWNTIME SyntheticsDowntimeResourceType = "downtime" +) + +var allowedSyntheticsDowntimeResourceTypeEnumValues = []SyntheticsDowntimeResourceType{ + SYNTHETICSDOWNTIMERESOURCETYPE_DOWNTIME, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SyntheticsDowntimeResourceType) GetAllowedValues() []SyntheticsDowntimeResourceType { + return allowedSyntheticsDowntimeResourceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SyntheticsDowntimeResourceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SyntheticsDowntimeResourceType(value) + return nil +} + +// NewSyntheticsDowntimeResourceTypeFromValue returns a pointer to a valid SyntheticsDowntimeResourceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSyntheticsDowntimeResourceTypeFromValue(v string) (*SyntheticsDowntimeResourceType, error) { + ev := SyntheticsDowntimeResourceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SyntheticsDowntimeResourceType: valid values are %v", v, allowedSyntheticsDowntimeResourceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SyntheticsDowntimeResourceType) IsValid() bool { + for _, existing := range allowedSyntheticsDowntimeResourceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SyntheticsDowntimeResourceType value. +func (v SyntheticsDowntimeResourceType) Ptr() *SyntheticsDowntimeResourceType { + return &v +} diff --git a/api/datadogV2/model_synthetics_downtime_response.go b/api/datadogV2/model_synthetics_downtime_response.go new file mode 100644 index 00000000000..58b244703fa --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_response.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsDowntimeResponse Response containing a single Synthetics downtime. +type SyntheticsDowntimeResponse struct { + // A Synthetics downtime object. + Data SyntheticsDowntimeData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsDowntimeResponse instantiates a new SyntheticsDowntimeResponse 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 NewSyntheticsDowntimeResponse(data SyntheticsDowntimeData) *SyntheticsDowntimeResponse { + this := SyntheticsDowntimeResponse{} + this.Data = data + return &this +} + +// NewSyntheticsDowntimeResponseWithDefaults instantiates a new SyntheticsDowntimeResponse 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 NewSyntheticsDowntimeResponseWithDefaults() *SyntheticsDowntimeResponse { + this := SyntheticsDowntimeResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *SyntheticsDowntimeResponse) GetData() SyntheticsDowntimeData { + if o == nil { + var ret SyntheticsDowntimeData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeResponse) GetDataOk() (*SyntheticsDowntimeData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *SyntheticsDowntimeResponse) SetData(v SyntheticsDowntimeData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *SyntheticsDowntimeData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_time_slot_date.go b/api/datadogV2/model_synthetics_downtime_time_slot_date.go new file mode 100644 index 00000000000..0716f04aa94 --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_time_slot_date.go @@ -0,0 +1,229 @@ +// 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" +) + +// SyntheticsDowntimeTimeSlotDate A specific date and time used to define the start or end of a Synthetics downtime time slot. +type SyntheticsDowntimeTimeSlotDate struct { + // The day component of the date (1-31). + Day int64 `json:"day"` + // The hour component of the time (0-23). + Hour int64 `json:"hour"` + // The minute component of the time (0-59). + Minute int64 `json:"minute"` + // The month component of the date (1-12). + Month int64 `json:"month"` + // The year component of the date. + Year int64 `json:"year"` + // 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:"-"` +} + +// NewSyntheticsDowntimeTimeSlotDate instantiates a new SyntheticsDowntimeTimeSlotDate 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 NewSyntheticsDowntimeTimeSlotDate(day int64, hour int64, minute int64, month int64, year int64) *SyntheticsDowntimeTimeSlotDate { + this := SyntheticsDowntimeTimeSlotDate{} + this.Day = day + this.Hour = hour + this.Minute = minute + this.Month = month + this.Year = year + return &this +} + +// NewSyntheticsDowntimeTimeSlotDateWithDefaults instantiates a new SyntheticsDowntimeTimeSlotDate 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 NewSyntheticsDowntimeTimeSlotDateWithDefaults() *SyntheticsDowntimeTimeSlotDate { + this := SyntheticsDowntimeTimeSlotDate{} + return &this +} + +// GetDay returns the Day field value. +func (o *SyntheticsDowntimeTimeSlotDate) GetDay() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Day +} + +// GetDayOk returns a tuple with the Day field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotDate) GetDayOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Day, true +} + +// SetDay sets field value. +func (o *SyntheticsDowntimeTimeSlotDate) SetDay(v int64) { + o.Day = v +} + +// GetHour returns the Hour field value. +func (o *SyntheticsDowntimeTimeSlotDate) GetHour() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Hour +} + +// GetHourOk returns a tuple with the Hour field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotDate) GetHourOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Hour, true +} + +// SetHour sets field value. +func (o *SyntheticsDowntimeTimeSlotDate) SetHour(v int64) { + o.Hour = v +} + +// GetMinute returns the Minute field value. +func (o *SyntheticsDowntimeTimeSlotDate) GetMinute() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Minute +} + +// GetMinuteOk returns a tuple with the Minute field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotDate) GetMinuteOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Minute, true +} + +// SetMinute sets field value. +func (o *SyntheticsDowntimeTimeSlotDate) SetMinute(v int64) { + o.Minute = v +} + +// GetMonth returns the Month field value. +func (o *SyntheticsDowntimeTimeSlotDate) GetMonth() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Month +} + +// GetMonthOk returns a tuple with the Month field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotDate) GetMonthOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Month, true +} + +// SetMonth sets field value. +func (o *SyntheticsDowntimeTimeSlotDate) SetMonth(v int64) { + o.Month = v +} + +// GetYear returns the Year field value. +func (o *SyntheticsDowntimeTimeSlotDate) GetYear() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Year +} + +// GetYearOk returns a tuple with the Year field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotDate) GetYearOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Year, true +} + +// SetYear sets field value. +func (o *SyntheticsDowntimeTimeSlotDate) SetYear(v int64) { + o.Year = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeTimeSlotDate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["day"] = o.Day + toSerialize["hour"] = o.Hour + toSerialize["minute"] = o.Minute + toSerialize["month"] = o.Month + toSerialize["year"] = o.Year + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeTimeSlotDate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Day *int64 `json:"day"` + Hour *int64 `json:"hour"` + Minute *int64 `json:"minute"` + Month *int64 `json:"month"` + Year *int64 `json:"year"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Day == nil { + return fmt.Errorf("required field day missing") + } + if all.Hour == nil { + return fmt.Errorf("required field hour missing") + } + if all.Minute == nil { + return fmt.Errorf("required field minute missing") + } + if all.Month == nil { + return fmt.Errorf("required field month missing") + } + if all.Year == nil { + return fmt.Errorf("required field year missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"day", "hour", "minute", "month", "year"}) + } else { + return err + } + o.Day = *all.Day + o.Hour = *all.Hour + o.Minute = *all.Minute + o.Month = *all.Month + o.Year = *all.Year + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_time_slot_recurrence_request.go b/api/datadogV2/model_synthetics_downtime_time_slot_recurrence_request.go new file mode 100644 index 00000000000..35c7fe61d46 --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_time_slot_recurrence_request.go @@ -0,0 +1,219 @@ +// 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" +) + +// SyntheticsDowntimeTimeSlotRecurrenceRequest Recurrence settings for a Synthetics downtime time slot. +type SyntheticsDowntimeTimeSlotRecurrenceRequest struct { + // A specific date and time used to define the start or end of a Synthetics downtime time slot. + End *SyntheticsDowntimeTimeSlotDate `json:"end,omitempty"` + // The recurrence frequency of a Synthetics downtime time slot. + Frequency SyntheticsDowntimeFrequency `json:"frequency"` + // The interval between recurrences, relative to the frequency. + Interval *int64 `json:"interval,omitempty"` + // Days of the week for a Synthetics downtime recurrence schedule. + Weekdays []SyntheticsDowntimeWeekday `json:"weekdays,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:"-"` +} + +// NewSyntheticsDowntimeTimeSlotRecurrenceRequest instantiates a new SyntheticsDowntimeTimeSlotRecurrenceRequest 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 NewSyntheticsDowntimeTimeSlotRecurrenceRequest(frequency SyntheticsDowntimeFrequency) *SyntheticsDowntimeTimeSlotRecurrenceRequest { + this := SyntheticsDowntimeTimeSlotRecurrenceRequest{} + this.Frequency = frequency + return &this +} + +// NewSyntheticsDowntimeTimeSlotRecurrenceRequestWithDefaults instantiates a new SyntheticsDowntimeTimeSlotRecurrenceRequest 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 NewSyntheticsDowntimeTimeSlotRecurrenceRequestWithDefaults() *SyntheticsDowntimeTimeSlotRecurrenceRequest { + this := SyntheticsDowntimeTimeSlotRecurrenceRequest{} + return &this +} + +// GetEnd returns the End field value if set, zero value otherwise. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) GetEnd() SyntheticsDowntimeTimeSlotDate { + if o == nil || o.End == nil { + var ret SyntheticsDowntimeTimeSlotDate + return ret + } + return *o.End +} + +// GetEndOk returns a tuple with the End field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) GetEndOk() (*SyntheticsDowntimeTimeSlotDate, bool) { + if o == nil || o.End == nil { + return nil, false + } + return o.End, true +} + +// HasEnd returns a boolean if a field has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) HasEnd() bool { + return o != nil && o.End != nil +} + +// SetEnd gets a reference to the given SyntheticsDowntimeTimeSlotDate and assigns it to the End field. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) SetEnd(v SyntheticsDowntimeTimeSlotDate) { + o.End = &v +} + +// GetFrequency returns the Frequency field value. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) GetFrequency() SyntheticsDowntimeFrequency { + if o == nil { + var ret SyntheticsDowntimeFrequency + return ret + } + return o.Frequency +} + +// GetFrequencyOk returns a tuple with the Frequency field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) GetFrequencyOk() (*SyntheticsDowntimeFrequency, bool) { + if o == nil { + return nil, false + } + return &o.Frequency, true +} + +// SetFrequency sets field value. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) SetFrequency(v SyntheticsDowntimeFrequency) { + o.Frequency = v +} + +// GetInterval returns the Interval field value if set, zero value otherwise. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) GetInterval() int64 { + if o == nil || o.Interval == nil { + var ret int64 + return ret + } + return *o.Interval +} + +// GetIntervalOk returns a tuple with the Interval field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) GetIntervalOk() (*int64, bool) { + if o == nil || o.Interval == nil { + return nil, false + } + return o.Interval, true +} + +// HasInterval returns a boolean if a field has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) HasInterval() bool { + return o != nil && o.Interval != nil +} + +// SetInterval gets a reference to the given int64 and assigns it to the Interval field. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) SetInterval(v int64) { + o.Interval = &v +} + +// GetWeekdays returns the Weekdays field value if set, zero value otherwise. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) GetWeekdays() []SyntheticsDowntimeWeekday { + if o == nil || o.Weekdays == nil { + var ret []SyntheticsDowntimeWeekday + return ret + } + return o.Weekdays +} + +// GetWeekdaysOk returns a tuple with the Weekdays field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) GetWeekdaysOk() (*[]SyntheticsDowntimeWeekday, bool) { + if o == nil || o.Weekdays == nil { + return nil, false + } + return &o.Weekdays, true +} + +// HasWeekdays returns a boolean if a field has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) HasWeekdays() bool { + return o != nil && o.Weekdays != nil +} + +// SetWeekdays gets a reference to the given []SyntheticsDowntimeWeekday and assigns it to the Weekdays field. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) SetWeekdays(v []SyntheticsDowntimeWeekday) { + o.Weekdays = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeTimeSlotRecurrenceRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.End != nil { + toSerialize["end"] = o.End + } + toSerialize["frequency"] = o.Frequency + if o.Interval != nil { + toSerialize["interval"] = o.Interval + } + if o.Weekdays != nil { + toSerialize["weekdays"] = o.Weekdays + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeTimeSlotRecurrenceRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + End *SyntheticsDowntimeTimeSlotDate `json:"end,omitempty"` + Frequency *SyntheticsDowntimeFrequency `json:"frequency"` + Interval *int64 `json:"interval,omitempty"` + Weekdays []SyntheticsDowntimeWeekday `json:"weekdays,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Frequency == nil { + return fmt.Errorf("required field frequency missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"end", "frequency", "interval", "weekdays"}) + } else { + return err + } + + hasInvalidField := false + if all.End != nil && all.End.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.End = all.End + if !all.Frequency.IsValid() { + hasInvalidField = true + } else { + o.Frequency = *all.Frequency + } + o.Interval = all.Interval + o.Weekdays = all.Weekdays + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_time_slot_recurrence_response.go b/api/datadogV2/model_synthetics_downtime_time_slot_recurrence_response.go new file mode 100644 index 00000000000..10f2d557172 --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_time_slot_recurrence_response.go @@ -0,0 +1,213 @@ +// 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" +) + +// SyntheticsDowntimeTimeSlotRecurrenceResponse Recurrence settings returned in a Synthetics downtime time slot response. +type SyntheticsDowntimeTimeSlotRecurrenceResponse struct { + // The recurrence frequency of a Synthetics downtime time slot. + Frequency SyntheticsDowntimeFrequency `json:"frequency"` + // The interval between recurrences, relative to the frequency. + Interval int64 `json:"interval"` + // A specific date and time used to define the start or end of a Synthetics downtime time slot. + Until *SyntheticsDowntimeTimeSlotDate `json:"until,omitempty"` + // Days of the week for a Synthetics downtime recurrence schedule. + Weekdays []SyntheticsDowntimeWeekday `json:"weekdays"` + // 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:"-"` +} + +// NewSyntheticsDowntimeTimeSlotRecurrenceResponse instantiates a new SyntheticsDowntimeTimeSlotRecurrenceResponse 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 NewSyntheticsDowntimeTimeSlotRecurrenceResponse(frequency SyntheticsDowntimeFrequency, interval int64, weekdays []SyntheticsDowntimeWeekday) *SyntheticsDowntimeTimeSlotRecurrenceResponse { + this := SyntheticsDowntimeTimeSlotRecurrenceResponse{} + this.Frequency = frequency + this.Interval = interval + this.Weekdays = weekdays + return &this +} + +// NewSyntheticsDowntimeTimeSlotRecurrenceResponseWithDefaults instantiates a new SyntheticsDowntimeTimeSlotRecurrenceResponse 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 NewSyntheticsDowntimeTimeSlotRecurrenceResponseWithDefaults() *SyntheticsDowntimeTimeSlotRecurrenceResponse { + this := SyntheticsDowntimeTimeSlotRecurrenceResponse{} + return &this +} + +// GetFrequency returns the Frequency field value. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) GetFrequency() SyntheticsDowntimeFrequency { + if o == nil { + var ret SyntheticsDowntimeFrequency + return ret + } + return o.Frequency +} + +// GetFrequencyOk returns a tuple with the Frequency field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) GetFrequencyOk() (*SyntheticsDowntimeFrequency, bool) { + if o == nil { + return nil, false + } + return &o.Frequency, true +} + +// SetFrequency sets field value. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) SetFrequency(v SyntheticsDowntimeFrequency) { + o.Frequency = v +} + +// GetInterval returns the Interval field value. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) GetInterval() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Interval +} + +// GetIntervalOk returns a tuple with the Interval field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) GetIntervalOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Interval, true +} + +// SetInterval sets field value. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) SetInterval(v int64) { + o.Interval = v +} + +// GetUntil returns the Until field value if set, zero value otherwise. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) GetUntil() SyntheticsDowntimeTimeSlotDate { + if o == nil || o.Until == nil { + var ret SyntheticsDowntimeTimeSlotDate + return ret + } + return *o.Until +} + +// GetUntilOk returns a tuple with the Until field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) GetUntilOk() (*SyntheticsDowntimeTimeSlotDate, bool) { + if o == nil || o.Until == nil { + return nil, false + } + return o.Until, true +} + +// HasUntil returns a boolean if a field has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) HasUntil() bool { + return o != nil && o.Until != nil +} + +// SetUntil gets a reference to the given SyntheticsDowntimeTimeSlotDate and assigns it to the Until field. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) SetUntil(v SyntheticsDowntimeTimeSlotDate) { + o.Until = &v +} + +// GetWeekdays returns the Weekdays field value. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) GetWeekdays() []SyntheticsDowntimeWeekday { + if o == nil { + var ret []SyntheticsDowntimeWeekday + return ret + } + return o.Weekdays +} + +// GetWeekdaysOk returns a tuple with the Weekdays field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) GetWeekdaysOk() (*[]SyntheticsDowntimeWeekday, bool) { + if o == nil { + return nil, false + } + return &o.Weekdays, true +} + +// SetWeekdays sets field value. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) SetWeekdays(v []SyntheticsDowntimeWeekday) { + o.Weekdays = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeTimeSlotRecurrenceResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["frequency"] = o.Frequency + toSerialize["interval"] = o.Interval + if o.Until != nil { + toSerialize["until"] = o.Until + } + toSerialize["weekdays"] = o.Weekdays + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeTimeSlotRecurrenceResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Frequency *SyntheticsDowntimeFrequency `json:"frequency"` + Interval *int64 `json:"interval"` + Until *SyntheticsDowntimeTimeSlotDate `json:"until,omitempty"` + Weekdays *[]SyntheticsDowntimeWeekday `json:"weekdays"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Frequency == nil { + return fmt.Errorf("required field frequency missing") + } + if all.Interval == nil { + return fmt.Errorf("required field interval missing") + } + if all.Weekdays == nil { + return fmt.Errorf("required field weekdays missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"frequency", "interval", "until", "weekdays"}) + } else { + return err + } + + hasInvalidField := false + if !all.Frequency.IsValid() { + hasInvalidField = true + } else { + o.Frequency = *all.Frequency + } + o.Interval = *all.Interval + if all.Until != nil && all.Until.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Until = all.Until + o.Weekdays = *all.Weekdays + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_time_slot_request.go b/api/datadogV2/model_synthetics_downtime_time_slot_request.go new file mode 100644 index 00000000000..89a3649b417 --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_time_slot_request.go @@ -0,0 +1,247 @@ +// 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" +) + +// SyntheticsDowntimeTimeSlotRequest A time slot for a Synthetics downtime create or update request. +type SyntheticsDowntimeTimeSlotRequest struct { + // The duration of the time slot in seconds, between 60 and 604800. + Duration int64 `json:"duration"` + // An optional label for the time slot. + Name *string `json:"name,omitempty"` + // Recurrence settings for a Synthetics downtime time slot. + Recurrence *SyntheticsDowntimeTimeSlotRecurrenceRequest `json:"recurrence,omitempty"` + // A specific date and time used to define the start or end of a Synthetics downtime time slot. + Start SyntheticsDowntimeTimeSlotDate `json:"start"` + // The IANA timezone name for the time slot. + Timezone string `json:"timezone"` + // 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:"-"` +} + +// NewSyntheticsDowntimeTimeSlotRequest instantiates a new SyntheticsDowntimeTimeSlotRequest 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 NewSyntheticsDowntimeTimeSlotRequest(duration int64, start SyntheticsDowntimeTimeSlotDate, timezone string) *SyntheticsDowntimeTimeSlotRequest { + this := SyntheticsDowntimeTimeSlotRequest{} + this.Duration = duration + this.Start = start + this.Timezone = timezone + return &this +} + +// NewSyntheticsDowntimeTimeSlotRequestWithDefaults instantiates a new SyntheticsDowntimeTimeSlotRequest 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 NewSyntheticsDowntimeTimeSlotRequestWithDefaults() *SyntheticsDowntimeTimeSlotRequest { + this := SyntheticsDowntimeTimeSlotRequest{} + return &this +} + +// GetDuration returns the Duration field value. +func (o *SyntheticsDowntimeTimeSlotRequest) GetDuration() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Duration +} + +// GetDurationOk returns a tuple with the Duration field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRequest) GetDurationOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Duration, true +} + +// SetDuration sets field value. +func (o *SyntheticsDowntimeTimeSlotRequest) SetDuration(v int64) { + o.Duration = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *SyntheticsDowntimeTimeSlotRequest) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRequest) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *SyntheticsDowntimeTimeSlotRequest) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *SyntheticsDowntimeTimeSlotRequest) SetName(v string) { + o.Name = &v +} + +// GetRecurrence returns the Recurrence field value if set, zero value otherwise. +func (o *SyntheticsDowntimeTimeSlotRequest) GetRecurrence() SyntheticsDowntimeTimeSlotRecurrenceRequest { + if o == nil || o.Recurrence == nil { + var ret SyntheticsDowntimeTimeSlotRecurrenceRequest + return ret + } + return *o.Recurrence +} + +// GetRecurrenceOk returns a tuple with the Recurrence field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRequest) GetRecurrenceOk() (*SyntheticsDowntimeTimeSlotRecurrenceRequest, bool) { + if o == nil || o.Recurrence == nil { + return nil, false + } + return o.Recurrence, true +} + +// HasRecurrence returns a boolean if a field has been set. +func (o *SyntheticsDowntimeTimeSlotRequest) HasRecurrence() bool { + return o != nil && o.Recurrence != nil +} + +// SetRecurrence gets a reference to the given SyntheticsDowntimeTimeSlotRecurrenceRequest and assigns it to the Recurrence field. +func (o *SyntheticsDowntimeTimeSlotRequest) SetRecurrence(v SyntheticsDowntimeTimeSlotRecurrenceRequest) { + o.Recurrence = &v +} + +// GetStart returns the Start field value. +func (o *SyntheticsDowntimeTimeSlotRequest) GetStart() SyntheticsDowntimeTimeSlotDate { + if o == nil { + var ret SyntheticsDowntimeTimeSlotDate + return ret + } + return o.Start +} + +// GetStartOk returns a tuple with the Start field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRequest) GetStartOk() (*SyntheticsDowntimeTimeSlotDate, bool) { + if o == nil { + return nil, false + } + return &o.Start, true +} + +// SetStart sets field value. +func (o *SyntheticsDowntimeTimeSlotRequest) SetStart(v SyntheticsDowntimeTimeSlotDate) { + o.Start = v +} + +// GetTimezone returns the Timezone field value. +func (o *SyntheticsDowntimeTimeSlotRequest) GetTimezone() string { + if o == nil { + var ret string + return ret + } + return o.Timezone +} + +// GetTimezoneOk returns a tuple with the Timezone field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotRequest) GetTimezoneOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Timezone, true +} + +// SetTimezone sets field value. +func (o *SyntheticsDowntimeTimeSlotRequest) SetTimezone(v string) { + o.Timezone = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeTimeSlotRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["duration"] = o.Duration + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Recurrence != nil { + toSerialize["recurrence"] = o.Recurrence + } + toSerialize["start"] = o.Start + toSerialize["timezone"] = o.Timezone + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeTimeSlotRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Duration *int64 `json:"duration"` + Name *string `json:"name,omitempty"` + Recurrence *SyntheticsDowntimeTimeSlotRecurrenceRequest `json:"recurrence,omitempty"` + Start *SyntheticsDowntimeTimeSlotDate `json:"start"` + Timezone *string `json:"timezone"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Duration == nil { + return fmt.Errorf("required field duration missing") + } + if all.Start == nil { + return fmt.Errorf("required field start missing") + } + if all.Timezone == nil { + return fmt.Errorf("required field timezone missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"duration", "name", "recurrence", "start", "timezone"}) + } else { + return err + } + + hasInvalidField := false + o.Duration = *all.Duration + o.Name = all.Name + if all.Recurrence != nil && all.Recurrence.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Recurrence = all.Recurrence + if all.Start.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Start = *all.Start + o.Timezone = *all.Timezone + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_time_slot_response.go b/api/datadogV2/model_synthetics_downtime_time_slot_response.go new file mode 100644 index 00000000000..8e02d58616c --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_time_slot_response.go @@ -0,0 +1,279 @@ +// 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" +) + +// SyntheticsDowntimeTimeSlotResponse A time slot returned in a Synthetics downtime response. +type SyntheticsDowntimeTimeSlotResponse struct { + // The duration of the time slot in seconds. + Duration int64 `json:"duration"` + // The unique identifier of the time slot. + Id string `json:"id"` + // The label for the time slot. + Name *string `json:"name,omitempty"` + // Recurrence settings returned in a Synthetics downtime time slot response. + Recurrence *SyntheticsDowntimeTimeSlotRecurrenceResponse `json:"recurrence,omitempty"` + // A specific date and time used to define the start or end of a Synthetics downtime time slot. + Start SyntheticsDowntimeTimeSlotDate `json:"start"` + // The IANA timezone name for the time slot. + Timezone string `json:"timezone"` + // 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:"-"` +} + +// NewSyntheticsDowntimeTimeSlotResponse instantiates a new SyntheticsDowntimeTimeSlotResponse 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 NewSyntheticsDowntimeTimeSlotResponse(duration int64, id string, start SyntheticsDowntimeTimeSlotDate, timezone string) *SyntheticsDowntimeTimeSlotResponse { + this := SyntheticsDowntimeTimeSlotResponse{} + this.Duration = duration + this.Id = id + this.Start = start + this.Timezone = timezone + return &this +} + +// NewSyntheticsDowntimeTimeSlotResponseWithDefaults instantiates a new SyntheticsDowntimeTimeSlotResponse 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 NewSyntheticsDowntimeTimeSlotResponseWithDefaults() *SyntheticsDowntimeTimeSlotResponse { + this := SyntheticsDowntimeTimeSlotResponse{} + return &this +} + +// GetDuration returns the Duration field value. +func (o *SyntheticsDowntimeTimeSlotResponse) GetDuration() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Duration +} + +// GetDurationOk returns a tuple with the Duration field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotResponse) GetDurationOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Duration, true +} + +// SetDuration sets field value. +func (o *SyntheticsDowntimeTimeSlotResponse) SetDuration(v int64) { + o.Duration = v +} + +// GetId returns the Id field value. +func (o *SyntheticsDowntimeTimeSlotResponse) 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 *SyntheticsDowntimeTimeSlotResponse) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *SyntheticsDowntimeTimeSlotResponse) SetId(v string) { + o.Id = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *SyntheticsDowntimeTimeSlotResponse) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotResponse) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *SyntheticsDowntimeTimeSlotResponse) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *SyntheticsDowntimeTimeSlotResponse) SetName(v string) { + o.Name = &v +} + +// GetRecurrence returns the Recurrence field value if set, zero value otherwise. +func (o *SyntheticsDowntimeTimeSlotResponse) GetRecurrence() SyntheticsDowntimeTimeSlotRecurrenceResponse { + if o == nil || o.Recurrence == nil { + var ret SyntheticsDowntimeTimeSlotRecurrenceResponse + return ret + } + return *o.Recurrence +} + +// GetRecurrenceOk returns a tuple with the Recurrence field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotResponse) GetRecurrenceOk() (*SyntheticsDowntimeTimeSlotRecurrenceResponse, bool) { + if o == nil || o.Recurrence == nil { + return nil, false + } + return o.Recurrence, true +} + +// HasRecurrence returns a boolean if a field has been set. +func (o *SyntheticsDowntimeTimeSlotResponse) HasRecurrence() bool { + return o != nil && o.Recurrence != nil +} + +// SetRecurrence gets a reference to the given SyntheticsDowntimeTimeSlotRecurrenceResponse and assigns it to the Recurrence field. +func (o *SyntheticsDowntimeTimeSlotResponse) SetRecurrence(v SyntheticsDowntimeTimeSlotRecurrenceResponse) { + o.Recurrence = &v +} + +// GetStart returns the Start field value. +func (o *SyntheticsDowntimeTimeSlotResponse) GetStart() SyntheticsDowntimeTimeSlotDate { + if o == nil { + var ret SyntheticsDowntimeTimeSlotDate + return ret + } + return o.Start +} + +// GetStartOk returns a tuple with the Start field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotResponse) GetStartOk() (*SyntheticsDowntimeTimeSlotDate, bool) { + if o == nil { + return nil, false + } + return &o.Start, true +} + +// SetStart sets field value. +func (o *SyntheticsDowntimeTimeSlotResponse) SetStart(v SyntheticsDowntimeTimeSlotDate) { + o.Start = v +} + +// GetTimezone returns the Timezone field value. +func (o *SyntheticsDowntimeTimeSlotResponse) GetTimezone() string { + if o == nil { + var ret string + return ret + } + return o.Timezone +} + +// GetTimezoneOk returns a tuple with the Timezone field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimeTimeSlotResponse) GetTimezoneOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Timezone, true +} + +// SetTimezone sets field value. +func (o *SyntheticsDowntimeTimeSlotResponse) SetTimezone(v string) { + o.Timezone = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimeTimeSlotResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["duration"] = o.Duration + toSerialize["id"] = o.Id + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Recurrence != nil { + toSerialize["recurrence"] = o.Recurrence + } + toSerialize["start"] = o.Start + toSerialize["timezone"] = o.Timezone + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimeTimeSlotResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Duration *int64 `json:"duration"` + Id *string `json:"id"` + Name *string `json:"name,omitempty"` + Recurrence *SyntheticsDowntimeTimeSlotRecurrenceResponse `json:"recurrence,omitempty"` + Start *SyntheticsDowntimeTimeSlotDate `json:"start"` + Timezone *string `json:"timezone"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Duration == nil { + return fmt.Errorf("required field duration missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Start == nil { + return fmt.Errorf("required field start missing") + } + if all.Timezone == nil { + return fmt.Errorf("required field timezone missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"duration", "id", "name", "recurrence", "start", "timezone"}) + } else { + return err + } + + hasInvalidField := false + o.Duration = *all.Duration + o.Id = *all.Id + o.Name = all.Name + if all.Recurrence != nil && all.Recurrence.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Recurrence = all.Recurrence + if all.Start.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Start = *all.Start + o.Timezone = *all.Timezone + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_downtime_weekday.go b/api/datadogV2/model_synthetics_downtime_weekday.go new file mode 100644 index 00000000000..8d334f27c9f --- /dev/null +++ b/api/datadogV2/model_synthetics_downtime_weekday.go @@ -0,0 +1,76 @@ +// 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" +) + +// SyntheticsDowntimeWeekday A day of the week for a Synthetics downtime recurrence. +type SyntheticsDowntimeWeekday string + +// List of SyntheticsDowntimeWeekday. +const ( + SYNTHETICSDOWNTIMEWEEKDAY_MONDAY SyntheticsDowntimeWeekday = "MO" + SYNTHETICSDOWNTIMEWEEKDAY_TUESDAY SyntheticsDowntimeWeekday = "TU" + SYNTHETICSDOWNTIMEWEEKDAY_WEDNESDAY SyntheticsDowntimeWeekday = "WE" + SYNTHETICSDOWNTIMEWEEKDAY_THURSDAY SyntheticsDowntimeWeekday = "TH" + SYNTHETICSDOWNTIMEWEEKDAY_FRIDAY SyntheticsDowntimeWeekday = "FR" + SYNTHETICSDOWNTIMEWEEKDAY_SATURDAY SyntheticsDowntimeWeekday = "SA" + SYNTHETICSDOWNTIMEWEEKDAY_SUNDAY SyntheticsDowntimeWeekday = "SU" +) + +var allowedSyntheticsDowntimeWeekdayEnumValues = []SyntheticsDowntimeWeekday{ + SYNTHETICSDOWNTIMEWEEKDAY_MONDAY, + SYNTHETICSDOWNTIMEWEEKDAY_TUESDAY, + SYNTHETICSDOWNTIMEWEEKDAY_WEDNESDAY, + SYNTHETICSDOWNTIMEWEEKDAY_THURSDAY, + SYNTHETICSDOWNTIMEWEEKDAY_FRIDAY, + SYNTHETICSDOWNTIMEWEEKDAY_SATURDAY, + SYNTHETICSDOWNTIMEWEEKDAY_SUNDAY, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SyntheticsDowntimeWeekday) GetAllowedValues() []SyntheticsDowntimeWeekday { + return allowedSyntheticsDowntimeWeekdayEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SyntheticsDowntimeWeekday) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SyntheticsDowntimeWeekday(value) + return nil +} + +// NewSyntheticsDowntimeWeekdayFromValue returns a pointer to a valid SyntheticsDowntimeWeekday +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSyntheticsDowntimeWeekdayFromValue(v string) (*SyntheticsDowntimeWeekday, error) { + ev := SyntheticsDowntimeWeekday(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SyntheticsDowntimeWeekday: valid values are %v", v, allowedSyntheticsDowntimeWeekdayEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SyntheticsDowntimeWeekday) IsValid() bool { + for _, existing := range allowedSyntheticsDowntimeWeekdayEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SyntheticsDowntimeWeekday value. +func (v SyntheticsDowntimeWeekday) Ptr() *SyntheticsDowntimeWeekday { + return &v +} diff --git a/api/datadogV2/model_synthetics_downtimes_response.go b/api/datadogV2/model_synthetics_downtimes_response.go new file mode 100644 index 00000000000..0273b99a885 --- /dev/null +++ b/api/datadogV2/model_synthetics_downtimes_response.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsDowntimesResponse Response containing a list of Synthetics downtimes. +type SyntheticsDowntimesResponse struct { + // List of Synthetics downtime objects. + Data []SyntheticsDowntimeData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsDowntimesResponse instantiates a new SyntheticsDowntimesResponse 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 NewSyntheticsDowntimesResponse(data []SyntheticsDowntimeData) *SyntheticsDowntimesResponse { + this := SyntheticsDowntimesResponse{} + this.Data = data + return &this +} + +// NewSyntheticsDowntimesResponseWithDefaults instantiates a new SyntheticsDowntimesResponse 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 NewSyntheticsDowntimesResponseWithDefaults() *SyntheticsDowntimesResponse { + this := SyntheticsDowntimesResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *SyntheticsDowntimesResponse) GetData() []SyntheticsDowntimeData { + if o == nil { + var ret []SyntheticsDowntimeData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *SyntheticsDowntimesResponse) GetDataOk() (*[]SyntheticsDowntimeData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *SyntheticsDowntimesResponse) SetData(v []SyntheticsDowntimeData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsDowntimesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsDowntimesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]SyntheticsDowntimeData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/synthetics/AddTestToSyntheticsDowntime.go b/examples/v2/synthetics/AddTestToSyntheticsDowntime.go new file mode 100644 index 00000000000..8f3cf0ed541 --- /dev/null +++ b/examples/v2/synthetics/AddTestToSyntheticsDowntime.go @@ -0,0 +1,29 @@ +// Add a test to a Synthetics downtime returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.AddTestToSyntheticsDowntime(ctx, "00000000-0000-0000-0000-000000000001", "abc-def-123") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.AddTestToSyntheticsDowntime`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.AddTestToSyntheticsDowntime`:\n%s\n", responseContent) +} diff --git a/examples/v2/synthetics/CreateSyntheticsDowntime.go b/examples/v2/synthetics/CreateSyntheticsDowntime.go new file mode 100644 index 00000000000..f0d2540917c --- /dev/null +++ b/examples/v2/synthetics/CreateSyntheticsDowntime.go @@ -0,0 +1,54 @@ +// Create a Synthetics downtime returns "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.SyntheticsDowntimeRequest{ + Data: datadogV2.SyntheticsDowntimeDataRequest{ + Attributes: datadogV2.SyntheticsDowntimeDataAttributesRequest{ + IsEnabled: true, + Name: "Weekly maintenance", + TestIds: []string{ + "abc-def-123", + }, + TimeSlots: []datadogV2.SyntheticsDowntimeTimeSlotRequest{ + { + Duration: 3600, + Start: datadogV2.SyntheticsDowntimeTimeSlotDate{ + Day: 15, + Hour: 10, + Minute: 30, + Month: 1, + Year: 2024, + }, + Timezone: "Europe/Paris", + }, + }, + }, + Type: datadogV2.SYNTHETICSDOWNTIMERESOURCETYPE_DOWNTIME, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.CreateSyntheticsDowntime(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateSyntheticsDowntime`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateSyntheticsDowntime`:\n%s\n", responseContent) +} diff --git a/examples/v2/synthetics/DeleteSyntheticsDowntime.go b/examples/v2/synthetics/DeleteSyntheticsDowntime.go new file mode 100644 index 00000000000..d972ecce8e3 --- /dev/null +++ b/examples/v2/synthetics/DeleteSyntheticsDowntime.go @@ -0,0 +1,25 @@ +// Delete a Synthetics downtime returns "No Content" 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + r, err := api.DeleteSyntheticsDowntime(ctx, "00000000-0000-0000-0000-000000000001") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.DeleteSyntheticsDowntime`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/synthetics/GetSyntheticsDowntime.go b/examples/v2/synthetics/GetSyntheticsDowntime.go new file mode 100644 index 00000000000..437a46e49d6 --- /dev/null +++ b/examples/v2/synthetics/GetSyntheticsDowntime.go @@ -0,0 +1,29 @@ +// Get a Synthetics downtime returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.GetSyntheticsDowntime(ctx, "00000000-0000-0000-0000-000000000001") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.GetSyntheticsDowntime`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.GetSyntheticsDowntime`:\n%s\n", responseContent) +} diff --git a/examples/v2/synthetics/ListSyntheticsDowntimes.go b/examples/v2/synthetics/ListSyntheticsDowntimes.go new file mode 100644 index 00000000000..3c9fee361c2 --- /dev/null +++ b/examples/v2/synthetics/ListSyntheticsDowntimes.go @@ -0,0 +1,29 @@ +// List Synthetics downtimes returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.ListSyntheticsDowntimes(ctx, *datadogV2.NewListSyntheticsDowntimesOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.ListSyntheticsDowntimes`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.ListSyntheticsDowntimes`:\n%s\n", responseContent) +} diff --git a/examples/v2/synthetics/RemoveTestFromSyntheticsDowntime.go b/examples/v2/synthetics/RemoveTestFromSyntheticsDowntime.go new file mode 100644 index 00000000000..5e9bbd38c0f --- /dev/null +++ b/examples/v2/synthetics/RemoveTestFromSyntheticsDowntime.go @@ -0,0 +1,29 @@ +// Remove a test from a Synthetics downtime returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.RemoveTestFromSyntheticsDowntime(ctx, "00000000-0000-0000-0000-000000000001", "abc-def-123") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.RemoveTestFromSyntheticsDowntime`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.RemoveTestFromSyntheticsDowntime`:\n%s\n", responseContent) +} diff --git a/examples/v2/synthetics/UpdateSyntheticsDowntime.go b/examples/v2/synthetics/UpdateSyntheticsDowntime.go new file mode 100644 index 00000000000..0016d48c255 --- /dev/null +++ b/examples/v2/synthetics/UpdateSyntheticsDowntime.go @@ -0,0 +1,54 @@ +// Update a Synthetics downtime returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.SyntheticsDowntimeRequest{ + Data: datadogV2.SyntheticsDowntimeDataRequest{ + Attributes: datadogV2.SyntheticsDowntimeDataAttributesRequest{ + IsEnabled: true, + Name: "Weekly maintenance", + TestIds: []string{ + "abc-def-123", + }, + TimeSlots: []datadogV2.SyntheticsDowntimeTimeSlotRequest{ + { + Duration: 3600, + Start: datadogV2.SyntheticsDowntimeTimeSlotDate{ + Day: 15, + Hour: 10, + Minute: 30, + Month: 1, + Year: 2024, + }, + Timezone: "Europe/Paris", + }, + }, + }, + Type: datadogV2.SYNTHETICSDOWNTIMERESOURCETYPE_DOWNTIME, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.UpdateSyntheticsDowntime(ctx, "00000000-0000-0000-0000-000000000001", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.UpdateSyntheticsDowntime`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.UpdateSyntheticsDowntime`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/synthetics.feature b/tests/scenarios/features/v2/synthetics.feature index f847bc0e702..f43e2e2c997 100644 --- a/tests/scenarios/features/v2/synthetics.feature +++ b/tests/scenarios/features/v2/synthetics.feature @@ -33,6 +33,30 @@ Feature: Synthetics When the request is sent Then the response status is 204 No Content + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Add a test to a Synthetics downtime returns "Bad Request" response + Given new "AddTestToSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + And request contains "test_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Add a test to a Synthetics downtime returns "Not Found" response + Given new "AddTestToSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + And request contains "test_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Add a test to a Synthetics downtime returns "OK" response + Given new "AddTestToSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + And request contains "test_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/synthetics-orchestrating-managing Scenario: Bulk delete suites returns "API error response." response Given new "DeleteSyntheticsSuites" request @@ -91,6 +115,20 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Create a Synthetics downtime returns "Bad Request" response + Given new "CreateSyntheticsDowntime" request + And body with value {"data": {"attributes": {"isEnabled": true, "name": "Weekly maintenance", "testIds": ["abc-def-123"], "timeSlots": [{"duration": 3600, "start": {"day": 15, "hour": 10, "minute": 30, "month": 1, "year": 2024}, "timezone": "Europe/Paris"}]}, "type": "downtime"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Create a Synthetics downtime returns "Created" response + Given new "CreateSyntheticsDowntime" request + And body with value {"data": {"attributes": {"isEnabled": true, "name": "Weekly maintenance", "testIds": ["abc-def-123"], "timeSlots": [{"duration": 3600, "start": {"day": 15, "hour": 10, "minute": 30, "month": 1, "year": 2024}, "timezone": "Europe/Paris"}]}, "type": "downtime"}} + When the request is sent + Then the response status is 201 Created + @generated @skip @team:DataDog/synthetics-orchestrating-managing Scenario: Create a test suite returns "API error response." response Given new "CreateSyntheticsSuite" request @@ -105,6 +143,27 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Delete a Synthetics downtime returns "Bad Request" response + Given new "DeleteSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Delete a Synthetics downtime returns "No Content" response + Given new "DeleteSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Delete a Synthetics downtime returns "Not Found" response + Given new "DeleteSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/synthetics-orchestrating-managing Scenario: Edit a Network Path test returns "API error response." response Given new "UpdateSyntheticsNetworkTest" request @@ -151,6 +210,27 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Get a Synthetics downtime returns "Bad Request" response + Given new "GetSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Get a Synthetics downtime returns "Not Found" response + Given new "GetSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Get a Synthetics downtime returns "OK" response + Given new "GetSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/synthetics-orchestrating-managing Scenario: Get a browser test result returns "API error response." response Given new "GetSyntheticsBrowserTestResult" request @@ -342,6 +422,18 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: List Synthetics downtimes returns "Bad Request" response + Given new "ListSyntheticsDowntimes" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: List Synthetics downtimes returns "OK" response + Given new "ListSyntheticsDowntimes" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/synthetics-orchestrating-managing Scenario: Patch a global variable returns "Bad Request" response Given new "PatchGlobalVariable" request @@ -396,6 +488,30 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Remove a test from a Synthetics downtime returns "Bad Request" response + Given new "RemoveTestFromSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + And request contains "test_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Remove a test from a Synthetics downtime returns "Not Found" response + Given new "RemoveTestFromSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + And request contains "test_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Remove a test from a Synthetics downtime returns "OK" response + Given new "RemoveTestFromSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + And request contains "test_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/synthetics-orchestrating-managing Scenario: Save new value for on-demand concurrency cap returns "OK" response Given new "SetOnDemandConcurrencyCap" request @@ -421,3 +537,27 @@ Feature: Synthetics Given new "SearchSuites" request When the request is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Update a Synthetics downtime returns "Bad Request" response + Given new "UpdateSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"isEnabled": true, "name": "Weekly maintenance", "testIds": ["abc-def-123"], "timeSlots": [{"duration": 3600, "start": {"day": 15, "hour": 10, "minute": 30, "month": 1, "year": 2024}, "timezone": "Europe/Paris"}]}, "type": "downtime"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Update a Synthetics downtime returns "Not Found" response + Given new "UpdateSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"isEnabled": true, "name": "Weekly maintenance", "testIds": ["abc-def-123"], "timeSlots": [{"duration": 3600, "start": {"day": 15, "hour": 10, "minute": 30, "month": 1, "year": 2024}, "timezone": "Europe/Paris"}]}, "type": "downtime"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/synthetics-orchestrating-managing + Scenario: Update a Synthetics downtime returns "OK" response + Given new "UpdateSyntheticsDowntime" request + And request contains "downtime_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"isEnabled": true, "name": "Weekly maintenance", "testIds": ["abc-def-123"], "timeSlots": [{"duration": 3600, "start": {"day": 15, "hour": 10, "minute": 30, "month": 1, "year": 2024}, "timezone": "Europe/Paris"}]}, "type": "downtime"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index efb20d6825d..36d1cdbe4c0 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -6410,6 +6410,69 @@ "type": "safe" } }, + "ListSyntheticsDowntimes": { + "tag": "Synthetics", + "undo": { + "type": "safe" + } + }, + "CreateSyntheticsDowntime": { + "tag": "Synthetics", + "undo": { + "operationId": "DeleteSyntheticsDowntime", + "parameters": [ + { + "name": "downtime_id", + "origin": "path", + "source": "downtime_id" + } + ], + "type": "unsafe" + } + }, + "DeleteSyntheticsDowntime": { + "tag": "Synthetics", + "undo": { + "type": "idempotent" + } + }, + "GetSyntheticsDowntime": { + "tag": "Synthetics", + "undo": { + "type": "safe" + } + }, + "UpdateSyntheticsDowntime": { + "tag": "Synthetics", + "undo": { + "type": "unsafe" + } + }, + "RemoveTestFromSyntheticsDowntime": { + "tag": "Synthetics", + "undo": { + "type": "idempotent" + } + }, + "AddTestToSyntheticsDowntime": { + "tag": "Synthetics", + "undo": { + "operationId": "RemoveTestFromSyntheticsDowntime", + "parameters": [ + { + "name": "downtime_id", + "origin": "path", + "source": "downtime_id" + }, + { + "name": "test_id", + "origin": "path", + "source": "test_id" + } + ], + "type": "unsafe" + } + }, "GetOnDemandConcurrencyCap": { "tag": "Synthetics", "undo": {