diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 27ad049e17c..f2d784e5d74 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -93,6 +93,43 @@ components: required: true schema: type: string + AnnotationEndTimeQueryParameter: + description: End of the time window in milliseconds since the Unix epoch. + example: 1704153600000 + in: query + name: end_time + required: true + schema: + format: int64 + type: integer + AnnotationIDPathParameter: + description: The ID of the annotation. + example: "00000000-0000-0000-0000-000000000000" + in: path + name: annotation_id + required: true + schema: + format: uuid + type: string + AnnotationPageIDPathParameter: + description: |- + The ID of the page, prefixed with the page type and joined by a colon + (for example, `dashboard:abc-def-xyz` or `notebook:1234567890`). + example: "dashboard:abc-def-xyz" + in: path + name: page_id + required: true + schema: + type: string + AnnotationStartTimeQueryParameter: + description: Start of the time window in milliseconds since the Unix epoch. + example: 1704067200000 + in: query + name: start_time + required: true + schema: + format: int64 + type: integer AnomalyID: description: The UUID of the cost anomaly. in: path @@ -4106,6 +4143,164 @@ components: - display - markdownTextAnnotation type: object + AnnotationAttributes: + description: Attributes of an annotation returned in a response. + properties: + author_id: + description: Identifier of the user who created the annotation. + example: "00000000-0000-0000-0000-000000000000" + type: string + color: + $ref: "#/components/schemas/AnnotationColor" + created_at: + description: Creation time of the annotation in milliseconds since the Unix epoch. + example: 1704067200000 + format: int64 + type: integer + description: + description: User-defined text attached to the annotation. + example: "Deployed v2.3.1 to production." + type: string + end_time: + description: End time of the annotation in milliseconds since the Unix epoch. Null for `pointInTime` annotations. + example: 1704070800000 + format: int64 + nullable: true + type: integer + modified_at: + description: Last modification time of the annotation in milliseconds since the Unix epoch. + example: 1704067200000 + format: int64 + type: integer + page_id: + description: |- + ID of the page the annotation belongs to, prefixed with the page type and joined by a colon + (for example, `dashboard:abc-def-xyz` or `notebook:1234567890`). + example: "dashboard:abc-def-xyz" + type: string + start_time: + description: Start time of the annotation in milliseconds since the Unix epoch. + example: 1704067200000 + format: int64 + type: integer + type: + $ref: "#/components/schemas/AnnotationKind" + widget_ids: + description: IDs of widgets the annotation is associated with. When empty or omitted, the annotation applies to the whole page. + example: + - "1234567890" + items: + description: Widget ID. + type: string + type: array + required: + - page_id + - description + - author_id + - type + - color + - start_time + - end_time + - created_at + - modified_at + type: object + AnnotationColor: + description: Color used to render the annotation in the UI. + enum: + - gray + - blue + - purple + - green + - yellow + - red + example: blue + type: string + x-enum-varnames: + - GRAY + - BLUE + - PURPLE + - GREEN + - YELLOW + - RED + AnnotationCreateAttributes: + description: Attributes for creating or updating an annotation. + properties: + color: + $ref: "#/components/schemas/AnnotationColor" + description: + description: User-defined text attached to the annotation. + example: "Deployed v2.3.1 to production." + type: string + end_time: + description: End time of the annotation in milliseconds since the Unix epoch. Required for `timeRegion` annotations; omit or set to null for `pointInTime` annotations. + example: 1704070800000 + format: int64 + nullable: true + type: integer + page_id: + description: |- + ID of the page the annotation belongs to, prefixed with the page type and joined by a colon + (for example, `dashboard:abc-def-xyz` or `notebook:1234567890`). + example: "dashboard:abc-def-xyz" + type: string + start_time: + description: Start time of the annotation in milliseconds since the Unix epoch. + example: 1704067200000 + format: int64 + type: integer + type: + $ref: "#/components/schemas/AnnotationKind" + widget_ids: + description: IDs of widgets the annotation is associated with. When empty or omitted, the annotation applies to the whole page. + example: + - "1234567890" + items: + description: Widget ID. + type: string + type: array + required: + - page_id + - description + - type + - color + - start_time + type: object + AnnotationCreateData: + description: Data for creating an annotation. + properties: + attributes: + $ref: "#/components/schemas/AnnotationCreateAttributes" + type: + $ref: "#/components/schemas/AnnotationType" + required: + - type + - attributes + type: object + AnnotationCreateRequest: + description: Request body for creating an annotation. + properties: + data: + $ref: "#/components/schemas/AnnotationCreateData" + required: + - data + type: object + AnnotationData: + description: A single annotation resource. + properties: + attributes: + $ref: "#/components/schemas/AnnotationAttributes" + id: + description: Unique identifier of the annotation. + example: "00000000-0000-0000-0000-000000000000" + format: uuid + type: string + type: + $ref: "#/components/schemas/AnnotationType" + required: + - id + - type + - attributes + type: object AnnotationDisplay: description: The definition of `AnnotationDisplay` object. properties: @@ -4132,6 +4327,85 @@ components: format: double type: number type: object + AnnotationInPage: + description: A flat annotation object as it appears within a page annotations response. + properties: + author_id: + description: Identifier of the user who created the annotation. + example: "00000000-0000-0000-0000-000000000000" + type: string + color: + $ref: "#/components/schemas/AnnotationColor" + created_at: + description: Creation time of the annotation in milliseconds since the Unix epoch. + example: 1704067200000 + format: int64 + type: integer + description: + description: User-defined text attached to the annotation. + example: "Deployed v2.3.1 to production." + type: string + end_time: + description: End time of the annotation in milliseconds since the Unix epoch. Null for `pointInTime` annotations. + example: 1704070800000 + format: int64 + nullable: true + type: integer + id: + description: Unique identifier of the annotation. + example: "00000000-0000-0000-0000-000000000000" + format: uuid + type: string + modified_at: + description: Last modification time of the annotation in milliseconds since the Unix epoch. + example: 1704067200000 + format: int64 + type: integer + page_id: + description: |- + ID of the page the annotation belongs to, prefixed with the page type and joined by a colon + (for example, `dashboard:abc-def-xyz` or `notebook:1234567890`). + example: "dashboard:abc-def-xyz" + type: string + start_time: + description: Start time of the annotation in milliseconds since the Unix epoch. + example: 1704067200000 + format: int64 + type: integer + type: + $ref: "#/components/schemas/AnnotationKind" + widget_ids: + description: IDs of widgets the annotation is associated with. When empty or omitted, the annotation applies to the whole page. + example: + - "1234567890" + items: + description: Widget ID. + type: string + type: array + required: + - id + - page_id + - description + - author_id + - type + - color + - start_time + - end_time + - created_at + - modified_at + type: object + AnnotationKind: + description: |- + Kind of annotation. `pointInTime` annotations mark a single moment in time, + while `timeRegion` annotations span a window of time and require an `end_time`. + enum: + - pointInTime + - timeRegion + example: pointInTime + type: string + x-enum-varnames: + - POINT_IN_TIME + - TIME_REGION AnnotationMarkdownTextAnnotation: description: The definition of `AnnotationMarkdownTextAnnotation` object. properties: @@ -4139,6 +4413,79 @@ components: description: The `markdownTextAnnotation` `text`. type: string type: object + AnnotationResponse: + description: Response containing a single annotation. + properties: + data: + $ref: "#/components/schemas/AnnotationData" + required: + - data + type: object + AnnotationType: + description: Annotation resource type. + enum: + - annotation + example: annotation + type: string + x-enum-varnames: + - ANNOTATION + AnnotationUpdateData: + description: Data for updating an annotation. + properties: + attributes: + $ref: "#/components/schemas/AnnotationCreateAttributes" + id: + description: Unique identifier of the annotation to update. + example: "00000000-0000-0000-0000-000000000000" + format: uuid + type: string + type: + $ref: "#/components/schemas/AnnotationType" + required: + - id + - type + - attributes + type: object + AnnotationUpdateRequest: + description: Request body for updating an annotation. + properties: + data: + $ref: "#/components/schemas/AnnotationUpdateData" + required: + - data + type: object + AnnotationsData: + description: List of annotation resources. + items: + $ref: "#/components/schemas/AnnotationData" + type: array + AnnotationsInPageMap: + additionalProperties: + $ref: "#/components/schemas/AnnotationInPage" + description: Map of annotation UUID to annotation object, keyed by annotation ID. + example: + "00000000-0000-0000-0000-000000000000": + author_id: "00000000-0000-0000-0000-000000000001" + color: blue + created_at: 1704067200000 + description: "Deployed v2.3.1 to production." + end_time: + id: "00000000-0000-0000-0000-000000000000" + modified_at: 1704067200000 + page_id: "dashboard:abc-def-xyz" + start_time: 1704067200000 + type: pointInTime + widget_ids: + - "1234567890" + type: object + AnnotationsResponse: + description: Response containing a list of annotations. + properties: + data: + $ref: "#/components/schemas/AnnotationsData" + required: + - data + type: object AnonymizeUserError: description: Error encountered when anonymizing a specific user. properties: @@ -34635,6 +34982,15 @@ components: required: - type type: object + GlobalAnnotationIds: + description: List of annotation IDs that apply to the entire page rather than a specific widget. + example: + - "00000000-0000-0000-0000-000000000001" + items: + description: Annotation ID. + format: uuid + type: string + type: array GlobalIncidentSettingsAttributesRequest: description: Global incident settings attributes properties: @@ -59259,6 +59615,54 @@ components: required: - data type: object + PageAnnotationsAttributes: + description: Attributes of the annotations on a page. + properties: + annotations: + $ref: "#/components/schemas/AnnotationsInPageMap" + global_annotations: + $ref: "#/components/schemas/GlobalAnnotationIds" + widget_mapping: + $ref: "#/components/schemas/WidgetAnnotationsMap" + required: + - annotations + - widget_mapping + - global_annotations + type: object + PageAnnotationsData: + description: Annotations grouped by widget for a single page. + properties: + attributes: + $ref: "#/components/schemas/PageAnnotationsAttributes" + id: + description: |- + ID of the page, prefixed with the page type and joined by a colon + (for example, `dashboard:abc-def-xyz` or `notebook:1234567890`). + example: "dashboard:abc-def-xyz" + type: string + type: + $ref: "#/components/schemas/PageAnnotationsType" + required: + - id + - type + - attributes + type: object + PageAnnotationsResponse: + description: Response containing all annotations on a page, grouped by widget. + properties: + data: + $ref: "#/components/schemas/PageAnnotationsData" + required: + - data + type: object + PageAnnotationsType: + description: Page annotations resource type. + enum: + - page_annotations + example: page_annotations + type: string + x-enum-varnames: + - PAGE_ANNOTATIONS PageUrgency: default: high description: On-Call Page urgency level. @@ -89375,6 +89779,23 @@ components: - FRIDAY - SATURDAY - SUNDAY + WidgetAnnotationIds: + description: List of annotation IDs displayed on a widget. + example: + - "00000000-0000-0000-0000-000000000000" + items: + description: Annotation ID. + format: uuid + type: string + type: array + WidgetAnnotationsMap: + additionalProperties: + $ref: "#/components/schemas/WidgetAnnotationIds" + description: Map from widget ID to the list of annotation IDs displayed on that widget. + example: + "1234567890": + - "00000000-0000-0000-0000-000000000000" + type: object WidgetAttributes: description: Attributes of a widget resource. properties: @@ -93609,6 +94030,366 @@ paths: operator: OR permissions: - security_monitoring_findings_read + /api/v2/annotation: + get: + description: Returns a flat list of annotations matching the given page, time window, and optional widget filter. + operationId: ListAnnotations + parameters: + - description: |- + ID of the page to list annotations for, prefixed with the page type and joined by a colon + (for example, `dashboard:abc-def-xyz` or `notebook:1234567890`). + example: "dashboard:abc-def-xyz" + in: query + name: page_id + required: true + schema: + type: string + - $ref: "#/components/parameters/AnnotationStartTimeQueryParameter" + - $ref: "#/components/parameters/AnnotationEndTimeQueryParameter" + - description: Optional widget ID to restrict results to annotations on a specific widget. + in: query + name: widget_id + required: false + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + author_id: "00000000-0000-0000-0000-000000000001" + color: blue + created_at: 1704067200000 + description: "Deployed v2.3.1 to production." + end_time: + modified_at: 1704067200000 + page_id: "dashboard:abc-def-xyz" + start_time: 1704067200000 + type: pointInTime + widget_ids: + - "1234567890" + id: "00000000-0000-0000-0000-000000000000" + type: annotation + schema: + $ref: "#/components/schemas/AnnotationsResponse" + 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" + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List annotations + tags: + - Annotations + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + post: + description: |- + Creates a new annotation on a dashboard or notebook page. + Valid `color` values: `gray`, `blue`, `purple`, `green`, `yellow`, `red`. + Valid `type` values: `pointInTime` (marks a single moment) or `timeRegion` (spans a range and requires `end_time`). + operationId: CreateAnnotation + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + color: blue + description: "Deployed v2.3.1 to production." + page_id: "dashboard:abc-def-xyz" + start_time: 1704067200000 + type: pointInTime + widget_ids: + - "1234567890" + type: annotation + schema: + $ref: "#/components/schemas/AnnotationCreateRequest" + description: Annotation to create. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + author_id: "00000000-0000-0000-0000-000000000001" + color: blue + created_at: 1704067200000 + description: "Deployed v2.3.1 to production." + end_time: + modified_at: 1704067200000 + page_id: "dashboard:abc-def-xyz" + start_time: 1704067200000 + type: pointInTime + widget_ids: + - "1234567890" + id: "00000000-0000-0000-0000-000000000000" + type: annotation + schema: + $ref: "#/components/schemas/AnnotationResponse" + 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" + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create an annotation + tags: + - Annotations + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/annotation/page/{page_id}: + get: + description: |- + Returns all annotations on a specific page for a given time window, grouped by widget. + Unlike `ListAnnotations`, this endpoint returns a single structured object with annotations + indexed by their ID and a widget-to-annotation mapping for easy UI rendering. + operationId: GetPageAnnotations + parameters: + - $ref: "#/components/parameters/AnnotationPageIDPathParameter" + - $ref: "#/components/parameters/AnnotationStartTimeQueryParameter" + - $ref: "#/components/parameters/AnnotationEndTimeQueryParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + annotations: + "00000000-0000-0000-0000-000000000000": + author_id: "00000000-0000-0000-0000-000000000001" + color: blue + created_at: 1704067200000 + description: "Deployed v2.3.1 to production." + end_time: + id: "00000000-0000-0000-0000-000000000000" + modified_at: 1704067200000 + page_id: "dashboard:abc-def-xyz" + start_time: 1704067200000 + type: pointInTime + widget_ids: + - "1234567890" + global_annotations: + - "00000000-0000-0000-0000-000000000002" + widget_mapping: + "1234567890": + - "00000000-0000-0000-0000-000000000000" + id: "dashboard:abc-def-xyz" + type: page_annotations + schema: + $ref: "#/components/schemas/PageAnnotationsResponse" + 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" + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get annotations for a page + tags: + - Annotations + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/annotation/{annotation_id}: + delete: + description: |- + Deletes an existing annotation by ID. + Returns `204 No Content` if the annotation does not exist (idempotent). + operationId: DeleteAnnotation + parameters: + - $ref: "#/components/parameters/AnnotationIDPathParameter" + responses: + "200": + description: OK + "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 + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Delete an annotation + tags: + - Annotations + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + put: + description: |- + Updates an existing annotation. + Valid `color` values: `gray`, `blue`, `purple`, `green`, `yellow`, `red`. + Valid `type` values: `pointInTime` (marks a single moment) or `timeRegion` (spans a range and requires `end_time`). + operationId: UpdateAnnotation + parameters: + - $ref: "#/components/parameters/AnnotationIDPathParameter" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + color: green + description: "Deployed v2.3.1 to production (updated)." + page_id: "dashboard:abc-def-xyz" + start_time: 1704067200000 + type: pointInTime + widget_ids: + - "1234567890" + id: "00000000-0000-0000-0000-000000000000" + type: annotation + schema: + $ref: "#/components/schemas/AnnotationUpdateRequest" + description: Updated annotation payload. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + author_id: "00000000-0000-0000-0000-000000000001" + color: green + created_at: 1704067200000 + description: "Deployed v2.3.1 to production (updated)." + end_time: + modified_at: 1704070800000 + page_id: "dashboard:abc-def-xyz" + start_time: 1704067200000 + type: pointInTime + widget_ids: + - "1234567890" + id: "00000000-0000-0000-0000-000000000000" + type: annotation + schema: + $ref: "#/components/schemas/AnnotationResponse" + 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" + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Update an annotation + tags: + - Annotations + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/anonymize_users: put: description: |- @@ -158410,6 +159191,8 @@ tags: Agentless offers also Sensitive Data Scanning capabilities on your storage. Go to https://www.datadoghq.com/blog/agentless-scanning/ to learn more. name: "Agentless Scanning" + - description: Add annotations to dashboards and notebooks to mark events such as deployments, incidents, or other notable moments in time. + name: Annotations - description: |- Datadog App Builder provides a low-code solution to rapidly develop and integrate secure, customized applications into your monitoring stack that are built to accelerate remediation at scale. These API endpoints allow you to create, read, update, delete, and publish apps. name: App Builder diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index f484c7357a4..4d99c0017f8 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -708,6 +708,11 @@ func NewConfiguration() *Configuration { "v2.UpdateLLMObsDatasetRecords": false, "v2.UpdateLLMObsExperiment": false, "v2.UpdateLLMObsProject": false, + "v2.CreateAnnotation": false, + "v2.DeleteAnnotation": false, + "v2.GetPageAnnotations": false, + "v2.ListAnnotations": false, + "v2.UpdateAnnotation": false, "v2.AnonymizeUsers": false, "v2.Validate": false, "v2.CreateOpenAPI": false, diff --git a/api/datadogV2/api_annotations.go b/api/datadogV2/api_annotations.go new file mode 100644 index 00000000000..d25dc53a9d0 --- /dev/null +++ b/api/datadogV2/api_annotations.go @@ -0,0 +1,540 @@ +// 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 ( + _context "context" + _fmt "fmt" + _log "log" + _nethttp "net/http" + _neturl "net/url" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/google/uuid" +) + +// AnnotationsApi service type +type AnnotationsApi datadog.Service + +// CreateAnnotation Create an annotation. +// Creates a new annotation on a dashboard or notebook page. +// Valid `color` values: `gray`, `blue`, `purple`, `green`, `yellow`, `red`. +// Valid `type` values: `pointInTime` (marks a single moment) or `timeRegion` (spans a range and requires `end_time`). +func (a *AnnotationsApi) CreateAnnotation(ctx _context.Context, body AnnotationCreateRequest) (AnnotationResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue AnnotationResponse + ) + + operationId := "v2.CreateAnnotation" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.AnnotationsApi.CreateAnnotation") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/annotation" + + 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 == 500 { + 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 +} + +// DeleteAnnotation Delete an annotation. +// Deletes an existing annotation by ID. +// Returns `204 No Content` if the annotation does not exist (idempotent). +func (a *AnnotationsApi) DeleteAnnotation(ctx _context.Context, annotationId uuid.UUID) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.DeleteAnnotation" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.AnnotationsApi.DeleteAnnotation") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/annotation/{annotation_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{annotation_id}", _neturl.PathEscape(datadog.ParameterToString(annotationId, ""))) + + 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 == 500 { + 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 +} + +// GetPageAnnotations Get annotations for a page. +// Returns all annotations on a specific page for a given time window, grouped by widget. +// Unlike `ListAnnotations`, this endpoint returns a single structured object with annotations +// indexed by their ID and a widget-to-annotation mapping for easy UI rendering. +func (a *AnnotationsApi) GetPageAnnotations(ctx _context.Context, pageId string, startTime int64, endTime int64) (PageAnnotationsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue PageAnnotationsResponse + ) + + operationId := "v2.GetPageAnnotations" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.AnnotationsApi.GetPageAnnotations") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/annotation/page/{page_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarQueryParams.Add("start_time", datadog.ParameterToString(startTime, "")) + localVarQueryParams.Add("end_time", datadog.ParameterToString(endTime, "")) + 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 == 500 { + 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 +} + +// ListAnnotationsOptionalParameters holds optional parameters for ListAnnotations. +type ListAnnotationsOptionalParameters struct { + WidgetId *string +} + +// NewListAnnotationsOptionalParameters creates an empty struct for parameters. +func NewListAnnotationsOptionalParameters() *ListAnnotationsOptionalParameters { + this := ListAnnotationsOptionalParameters{} + return &this +} + +// WithWidgetId sets the corresponding parameter name and returns the struct. +func (r *ListAnnotationsOptionalParameters) WithWidgetId(widgetId string) *ListAnnotationsOptionalParameters { + r.WidgetId = &widgetId + return r +} + +// ListAnnotations List annotations. +// Returns a flat list of annotations matching the given page, time window, and optional widget filter. +func (a *AnnotationsApi) ListAnnotations(ctx _context.Context, pageId string, startTime int64, endTime int64, o ...ListAnnotationsOptionalParameters) (AnnotationsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue AnnotationsResponse + optionalParams ListAnnotationsOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListAnnotationsOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ListAnnotations" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.AnnotationsApi.ListAnnotations") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/annotation" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarQueryParams.Add("page_id", datadog.ParameterToString(pageId, "")) + localVarQueryParams.Add("start_time", datadog.ParameterToString(startTime, "")) + localVarQueryParams.Add("end_time", datadog.ParameterToString(endTime, "")) + if optionalParams.WidgetId != nil { + localVarQueryParams.Add("widget_id", datadog.ParameterToString(*optionalParams.WidgetId, "")) + } + 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 == 500 { + 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 +} + +// UpdateAnnotation Update an annotation. +// Updates an existing annotation. +// Valid `color` values: `gray`, `blue`, `purple`, `green`, `yellow`, `red`. +// Valid `type` values: `pointInTime` (marks a single moment) or `timeRegion` (spans a range and requires `end_time`). +func (a *AnnotationsApi) UpdateAnnotation(ctx _context.Context, annotationId uuid.UUID, body AnnotationUpdateRequest) (AnnotationResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue AnnotationResponse + ) + + operationId := "v2.UpdateAnnotation" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.AnnotationsApi.UpdateAnnotation") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/annotation/{annotation_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{annotation_id}", _neturl.PathEscape(datadog.ParameterToString(annotationId, ""))) + + 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 || localVarHTTPResponse.StatusCode == 500 { + 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 +} + +// NewAnnotationsApi Returns NewAnnotationsApi. +func NewAnnotationsApi(client *datadog.APIClient) *AnnotationsApi { + return &AnnotationsApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 831ea089fab..b84409e852e 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -69,6 +69,11 @@ // - [AgentlessScanningApi.UpdateAwsScanOptions] // - [AgentlessScanningApi.UpdateAzureScanOptions] // - [AgentlessScanningApi.UpdateGcpScanOptions] +// - [AnnotationsApi.CreateAnnotation] +// - [AnnotationsApi.DeleteAnnotation] +// - [AnnotationsApi.GetPageAnnotations] +// - [AnnotationsApi.ListAnnotations] +// - [AnnotationsApi.UpdateAnnotation] // - [AppBuilderApi.CreateApp] // - [AppBuilderApi.CreatePublishRequest] // - [AppBuilderApi.DeleteApp] diff --git a/api/datadogV2/model_annotation_attributes.go b/api/datadogV2/model_annotation_attributes.go new file mode 100644 index 00000000000..5a79b66972f --- /dev/null +++ b/api/datadogV2/model_annotation_attributes.go @@ -0,0 +1,410 @@ +// 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" +) + +// AnnotationAttributes Attributes of an annotation returned in a response. +type AnnotationAttributes struct { + // Identifier of the user who created the annotation. + AuthorId string `json:"author_id"` + // Color used to render the annotation in the UI. + Color AnnotationColor `json:"color"` + // Creation time of the annotation in milliseconds since the Unix epoch. + CreatedAt int64 `json:"created_at"` + // User-defined text attached to the annotation. + Description string `json:"description"` + // End time of the annotation in milliseconds since the Unix epoch. Null for `pointInTime` annotations. + EndTime datadog.NullableInt64 `json:"end_time"` + // Last modification time of the annotation in milliseconds since the Unix epoch. + ModifiedAt int64 `json:"modified_at"` + // ID of the page the annotation belongs to, prefixed with the page type and joined by a colon + // (for example, `dashboard:abc-def-xyz` or `notebook:1234567890`). + PageId string `json:"page_id"` + // Start time of the annotation in milliseconds since the Unix epoch. + StartTime int64 `json:"start_time"` + // Kind of annotation. `pointInTime` annotations mark a single moment in time, + // while `timeRegion` annotations span a window of time and require an `end_time`. + Type AnnotationKind `json:"type"` + // IDs of widgets the annotation is associated with. When empty or omitted, the annotation applies to the whole page. + WidgetIds []string `json:"widget_ids,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:"-"` +} + +// NewAnnotationAttributes instantiates a new AnnotationAttributes 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 NewAnnotationAttributes(authorId string, color AnnotationColor, createdAt int64, description string, endTime datadog.NullableInt64, modifiedAt int64, pageId string, startTime int64, typeVar AnnotationKind) *AnnotationAttributes { + this := AnnotationAttributes{} + this.AuthorId = authorId + this.Color = color + this.CreatedAt = createdAt + this.Description = description + this.EndTime = endTime + this.ModifiedAt = modifiedAt + this.PageId = pageId + this.StartTime = startTime + this.Type = typeVar + return &this +} + +// NewAnnotationAttributesWithDefaults instantiates a new AnnotationAttributes 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 NewAnnotationAttributesWithDefaults() *AnnotationAttributes { + this := AnnotationAttributes{} + return &this +} + +// GetAuthorId returns the AuthorId field value. +func (o *AnnotationAttributes) GetAuthorId() string { + if o == nil { + var ret string + return ret + } + return o.AuthorId +} + +// GetAuthorIdOk returns a tuple with the AuthorId field value +// and a boolean to check if the value has been set. +func (o *AnnotationAttributes) GetAuthorIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AuthorId, true +} + +// SetAuthorId sets field value. +func (o *AnnotationAttributes) SetAuthorId(v string) { + o.AuthorId = v +} + +// GetColor returns the Color field value. +func (o *AnnotationAttributes) GetColor() AnnotationColor { + if o == nil { + var ret AnnotationColor + return ret + } + return o.Color +} + +// GetColorOk returns a tuple with the Color field value +// and a boolean to check if the value has been set. +func (o *AnnotationAttributes) GetColorOk() (*AnnotationColor, bool) { + if o == nil { + return nil, false + } + return &o.Color, true +} + +// SetColor sets field value. +func (o *AnnotationAttributes) SetColor(v AnnotationColor) { + o.Color = v +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *AnnotationAttributes) GetCreatedAt() int64 { + if o == nil { + var ret int64 + 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 *AnnotationAttributes) GetCreatedAtOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *AnnotationAttributes) SetCreatedAt(v int64) { + o.CreatedAt = v +} + +// GetDescription returns the Description field value. +func (o *AnnotationAttributes) 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 *AnnotationAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *AnnotationAttributes) SetDescription(v string) { + o.Description = v +} + +// GetEndTime returns the EndTime field value. +// If the value is explicit nil, the zero value for int64 will be returned. +func (o *AnnotationAttributes) GetEndTime() int64 { + if o == nil || o.EndTime.Get() == nil { + var ret int64 + return ret + } + return *o.EndTime.Get() +} + +// GetEndTimeOk returns a tuple with the EndTime field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *AnnotationAttributes) GetEndTimeOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.EndTime.Get(), o.EndTime.IsSet() +} + +// SetEndTime sets field value. +func (o *AnnotationAttributes) SetEndTime(v int64) { + o.EndTime.Set(&v) +} + +// GetModifiedAt returns the ModifiedAt field value. +func (o *AnnotationAttributes) GetModifiedAt() int64 { + if o == nil { + var ret int64 + return ret + } + return o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value +// and a boolean to check if the value has been set. +func (o *AnnotationAttributes) GetModifiedAtOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.ModifiedAt, true +} + +// SetModifiedAt sets field value. +func (o *AnnotationAttributes) SetModifiedAt(v int64) { + o.ModifiedAt = v +} + +// GetPageId returns the PageId field value. +func (o *AnnotationAttributes) GetPageId() string { + if o == nil { + var ret string + return ret + } + return o.PageId +} + +// GetPageIdOk returns a tuple with the PageId field value +// and a boolean to check if the value has been set. +func (o *AnnotationAttributes) GetPageIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PageId, true +} + +// SetPageId sets field value. +func (o *AnnotationAttributes) SetPageId(v string) { + o.PageId = v +} + +// GetStartTime returns the StartTime field value. +func (o *AnnotationAttributes) GetStartTime() int64 { + if o == nil { + var ret int64 + return ret + } + return o.StartTime +} + +// GetStartTimeOk returns a tuple with the StartTime field value +// and a boolean to check if the value has been set. +func (o *AnnotationAttributes) GetStartTimeOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.StartTime, true +} + +// SetStartTime sets field value. +func (o *AnnotationAttributes) SetStartTime(v int64) { + o.StartTime = v +} + +// GetType returns the Type field value. +func (o *AnnotationAttributes) GetType() AnnotationKind { + if o == nil { + var ret AnnotationKind + 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 *AnnotationAttributes) GetTypeOk() (*AnnotationKind, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AnnotationAttributes) SetType(v AnnotationKind) { + o.Type = v +} + +// GetWidgetIds returns the WidgetIds field value if set, zero value otherwise. +func (o *AnnotationAttributes) GetWidgetIds() []string { + if o == nil || o.WidgetIds == nil { + var ret []string + return ret + } + return o.WidgetIds +} + +// GetWidgetIdsOk returns a tuple with the WidgetIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AnnotationAttributes) GetWidgetIdsOk() (*[]string, bool) { + if o == nil || o.WidgetIds == nil { + return nil, false + } + return &o.WidgetIds, true +} + +// HasWidgetIds returns a boolean if a field has been set. +func (o *AnnotationAttributes) HasWidgetIds() bool { + return o != nil && o.WidgetIds != nil +} + +// SetWidgetIds gets a reference to the given []string and assigns it to the WidgetIds field. +func (o *AnnotationAttributes) SetWidgetIds(v []string) { + o.WidgetIds = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AnnotationAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["author_id"] = o.AuthorId + toSerialize["color"] = o.Color + toSerialize["created_at"] = o.CreatedAt + toSerialize["description"] = o.Description + toSerialize["end_time"] = o.EndTime.Get() + toSerialize["modified_at"] = o.ModifiedAt + toSerialize["page_id"] = o.PageId + toSerialize["start_time"] = o.StartTime + toSerialize["type"] = o.Type + if o.WidgetIds != nil { + toSerialize["widget_ids"] = o.WidgetIds + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AnnotationAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AuthorId *string `json:"author_id"` + Color *AnnotationColor `json:"color"` + CreatedAt *int64 `json:"created_at"` + Description *string `json:"description"` + EndTime datadog.NullableInt64 `json:"end_time"` + ModifiedAt *int64 `json:"modified_at"` + PageId *string `json:"page_id"` + StartTime *int64 `json:"start_time"` + Type *AnnotationKind `json:"type"` + WidgetIds []string `json:"widget_ids,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AuthorId == nil { + return fmt.Errorf("required field author_id missing") + } + if all.Color == nil { + return fmt.Errorf("required field color missing") + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if !all.EndTime.IsSet() { + return fmt.Errorf("required field end_time missing") + } + if all.ModifiedAt == nil { + return fmt.Errorf("required field modified_at missing") + } + if all.PageId == nil { + return fmt.Errorf("required field page_id missing") + } + if all.StartTime == nil { + return fmt.Errorf("required field start_time 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{"author_id", "color", "created_at", "description", "end_time", "modified_at", "page_id", "start_time", "type", "widget_ids"}) + } else { + return err + } + + hasInvalidField := false + o.AuthorId = *all.AuthorId + if !all.Color.IsValid() { + hasInvalidField = true + } else { + o.Color = *all.Color + } + o.CreatedAt = *all.CreatedAt + o.Description = *all.Description + o.EndTime = all.EndTime + o.ModifiedAt = *all.ModifiedAt + o.PageId = *all.PageId + o.StartTime = *all.StartTime + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.WidgetIds = all.WidgetIds + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_annotation_color.go b/api/datadogV2/model_annotation_color.go new file mode 100644 index 00000000000..8638d22eb58 --- /dev/null +++ b/api/datadogV2/model_annotation_color.go @@ -0,0 +1,74 @@ +// 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" +) + +// AnnotationColor Color used to render the annotation in the UI. +type AnnotationColor string + +// List of AnnotationColor. +const ( + ANNOTATIONCOLOR_GRAY AnnotationColor = "gray" + ANNOTATIONCOLOR_BLUE AnnotationColor = "blue" + ANNOTATIONCOLOR_PURPLE AnnotationColor = "purple" + ANNOTATIONCOLOR_GREEN AnnotationColor = "green" + ANNOTATIONCOLOR_YELLOW AnnotationColor = "yellow" + ANNOTATIONCOLOR_RED AnnotationColor = "red" +) + +var allowedAnnotationColorEnumValues = []AnnotationColor{ + ANNOTATIONCOLOR_GRAY, + ANNOTATIONCOLOR_BLUE, + ANNOTATIONCOLOR_PURPLE, + ANNOTATIONCOLOR_GREEN, + ANNOTATIONCOLOR_YELLOW, + ANNOTATIONCOLOR_RED, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AnnotationColor) GetAllowedValues() []AnnotationColor { + return allowedAnnotationColorEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AnnotationColor) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AnnotationColor(value) + return nil +} + +// NewAnnotationColorFromValue returns a pointer to a valid AnnotationColor +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAnnotationColorFromValue(v string) (*AnnotationColor, error) { + ev := AnnotationColor(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AnnotationColor: valid values are %v", v, allowedAnnotationColorEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AnnotationColor) IsValid() bool { + for _, existing := range allowedAnnotationColorEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AnnotationColor value. +func (v AnnotationColor) Ptr() *AnnotationColor { + return &v +} diff --git a/api/datadogV2/model_annotation_create_attributes.go b/api/datadogV2/model_annotation_create_attributes.go new file mode 100644 index 00000000000..324e7940e5d --- /dev/null +++ b/api/datadogV2/model_annotation_create_attributes.go @@ -0,0 +1,326 @@ +// 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" +) + +// AnnotationCreateAttributes Attributes for creating or updating an annotation. +type AnnotationCreateAttributes struct { + // Color used to render the annotation in the UI. + Color AnnotationColor `json:"color"` + // User-defined text attached to the annotation. + Description string `json:"description"` + // End time of the annotation in milliseconds since the Unix epoch. Required for `timeRegion` annotations; omit or set to null for `pointInTime` annotations. + EndTime datadog.NullableInt64 `json:"end_time,omitempty"` + // ID of the page the annotation belongs to, prefixed with the page type and joined by a colon + // (for example, `dashboard:abc-def-xyz` or `notebook:1234567890`). + PageId string `json:"page_id"` + // Start time of the annotation in milliseconds since the Unix epoch. + StartTime int64 `json:"start_time"` + // Kind of annotation. `pointInTime` annotations mark a single moment in time, + // while `timeRegion` annotations span a window of time and require an `end_time`. + Type AnnotationKind `json:"type"` + // IDs of widgets the annotation is associated with. When empty or omitted, the annotation applies to the whole page. + WidgetIds []string `json:"widget_ids,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:"-"` +} + +// NewAnnotationCreateAttributes instantiates a new AnnotationCreateAttributes 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 NewAnnotationCreateAttributes(color AnnotationColor, description string, pageId string, startTime int64, typeVar AnnotationKind) *AnnotationCreateAttributes { + this := AnnotationCreateAttributes{} + this.Color = color + this.Description = description + this.PageId = pageId + this.StartTime = startTime + this.Type = typeVar + return &this +} + +// NewAnnotationCreateAttributesWithDefaults instantiates a new AnnotationCreateAttributes 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 NewAnnotationCreateAttributesWithDefaults() *AnnotationCreateAttributes { + this := AnnotationCreateAttributes{} + return &this +} + +// GetColor returns the Color field value. +func (o *AnnotationCreateAttributes) GetColor() AnnotationColor { + if o == nil { + var ret AnnotationColor + return ret + } + return o.Color +} + +// GetColorOk returns a tuple with the Color field value +// and a boolean to check if the value has been set. +func (o *AnnotationCreateAttributes) GetColorOk() (*AnnotationColor, bool) { + if o == nil { + return nil, false + } + return &o.Color, true +} + +// SetColor sets field value. +func (o *AnnotationCreateAttributes) SetColor(v AnnotationColor) { + o.Color = v +} + +// GetDescription returns the Description field value. +func (o *AnnotationCreateAttributes) 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 *AnnotationCreateAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *AnnotationCreateAttributes) SetDescription(v string) { + o.Description = v +} + +// GetEndTime returns the EndTime field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *AnnotationCreateAttributes) GetEndTime() int64 { + if o == nil || o.EndTime.Get() == nil { + var ret int64 + return ret + } + return *o.EndTime.Get() +} + +// GetEndTimeOk returns a tuple with the EndTime field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *AnnotationCreateAttributes) GetEndTimeOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.EndTime.Get(), o.EndTime.IsSet() +} + +// HasEndTime returns a boolean if a field has been set. +func (o *AnnotationCreateAttributes) HasEndTime() bool { + return o != nil && o.EndTime.IsSet() +} + +// SetEndTime gets a reference to the given datadog.NullableInt64 and assigns it to the EndTime field. +func (o *AnnotationCreateAttributes) SetEndTime(v int64) { + o.EndTime.Set(&v) +} + +// SetEndTimeNil sets the value for EndTime to be an explicit nil. +func (o *AnnotationCreateAttributes) SetEndTimeNil() { + o.EndTime.Set(nil) +} + +// UnsetEndTime ensures that no value is present for EndTime, not even an explicit nil. +func (o *AnnotationCreateAttributes) UnsetEndTime() { + o.EndTime.Unset() +} + +// GetPageId returns the PageId field value. +func (o *AnnotationCreateAttributes) GetPageId() string { + if o == nil { + var ret string + return ret + } + return o.PageId +} + +// GetPageIdOk returns a tuple with the PageId field value +// and a boolean to check if the value has been set. +func (o *AnnotationCreateAttributes) GetPageIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PageId, true +} + +// SetPageId sets field value. +func (o *AnnotationCreateAttributes) SetPageId(v string) { + o.PageId = v +} + +// GetStartTime returns the StartTime field value. +func (o *AnnotationCreateAttributes) GetStartTime() int64 { + if o == nil { + var ret int64 + return ret + } + return o.StartTime +} + +// GetStartTimeOk returns a tuple with the StartTime field value +// and a boolean to check if the value has been set. +func (o *AnnotationCreateAttributes) GetStartTimeOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.StartTime, true +} + +// SetStartTime sets field value. +func (o *AnnotationCreateAttributes) SetStartTime(v int64) { + o.StartTime = v +} + +// GetType returns the Type field value. +func (o *AnnotationCreateAttributes) GetType() AnnotationKind { + if o == nil { + var ret AnnotationKind + 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 *AnnotationCreateAttributes) GetTypeOk() (*AnnotationKind, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AnnotationCreateAttributes) SetType(v AnnotationKind) { + o.Type = v +} + +// GetWidgetIds returns the WidgetIds field value if set, zero value otherwise. +func (o *AnnotationCreateAttributes) GetWidgetIds() []string { + if o == nil || o.WidgetIds == nil { + var ret []string + return ret + } + return o.WidgetIds +} + +// GetWidgetIdsOk returns a tuple with the WidgetIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AnnotationCreateAttributes) GetWidgetIdsOk() (*[]string, bool) { + if o == nil || o.WidgetIds == nil { + return nil, false + } + return &o.WidgetIds, true +} + +// HasWidgetIds returns a boolean if a field has been set. +func (o *AnnotationCreateAttributes) HasWidgetIds() bool { + return o != nil && o.WidgetIds != nil +} + +// SetWidgetIds gets a reference to the given []string and assigns it to the WidgetIds field. +func (o *AnnotationCreateAttributes) SetWidgetIds(v []string) { + o.WidgetIds = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AnnotationCreateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["color"] = o.Color + toSerialize["description"] = o.Description + if o.EndTime.IsSet() { + toSerialize["end_time"] = o.EndTime.Get() + } + toSerialize["page_id"] = o.PageId + toSerialize["start_time"] = o.StartTime + toSerialize["type"] = o.Type + if o.WidgetIds != nil { + toSerialize["widget_ids"] = o.WidgetIds + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AnnotationCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Color *AnnotationColor `json:"color"` + Description *string `json:"description"` + EndTime datadog.NullableInt64 `json:"end_time,omitempty"` + PageId *string `json:"page_id"` + StartTime *int64 `json:"start_time"` + Type *AnnotationKind `json:"type"` + WidgetIds []string `json:"widget_ids,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Color == nil { + return fmt.Errorf("required field color missing") + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.PageId == nil { + return fmt.Errorf("required field page_id missing") + } + if all.StartTime == nil { + return fmt.Errorf("required field start_time 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{"color", "description", "end_time", "page_id", "start_time", "type", "widget_ids"}) + } else { + return err + } + + hasInvalidField := false + if !all.Color.IsValid() { + hasInvalidField = true + } else { + o.Color = *all.Color + } + o.Description = *all.Description + o.EndTime = all.EndTime + o.PageId = *all.PageId + o.StartTime = *all.StartTime + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.WidgetIds = all.WidgetIds + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_annotation_create_data.go b/api/datadogV2/model_annotation_create_data.go new file mode 100644 index 00000000000..794fd33f17d --- /dev/null +++ b/api/datadogV2/model_annotation_create_data.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" +) + +// AnnotationCreateData Data for creating an annotation. +type AnnotationCreateData struct { + // Attributes for creating or updating an annotation. + Attributes AnnotationCreateAttributes `json:"attributes"` + // Annotation resource type. + Type AnnotationType `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:"-"` +} + +// NewAnnotationCreateData instantiates a new AnnotationCreateData 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 NewAnnotationCreateData(attributes AnnotationCreateAttributes, typeVar AnnotationType) *AnnotationCreateData { + this := AnnotationCreateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewAnnotationCreateDataWithDefaults instantiates a new AnnotationCreateData 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 NewAnnotationCreateDataWithDefaults() *AnnotationCreateData { + this := AnnotationCreateData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *AnnotationCreateData) GetAttributes() AnnotationCreateAttributes { + if o == nil { + var ret AnnotationCreateAttributes + 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 *AnnotationCreateData) GetAttributesOk() (*AnnotationCreateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *AnnotationCreateData) SetAttributes(v AnnotationCreateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *AnnotationCreateData) GetType() AnnotationType { + if o == nil { + var ret AnnotationType + 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 *AnnotationCreateData) GetTypeOk() (*AnnotationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AnnotationCreateData) SetType(v AnnotationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AnnotationCreateData) 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 *AnnotationCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *AnnotationCreateAttributes `json:"attributes"` + Type *AnnotationType `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_annotation_create_request.go b/api/datadogV2/model_annotation_create_request.go new file mode 100644 index 00000000000..6bd1e4be1e1 --- /dev/null +++ b/api/datadogV2/model_annotation_create_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" +) + +// AnnotationCreateRequest Request body for creating an annotation. +type AnnotationCreateRequest struct { + // Data for creating an annotation. + Data AnnotationCreateData `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:"-"` +} + +// NewAnnotationCreateRequest instantiates a new AnnotationCreateRequest 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 NewAnnotationCreateRequest(data AnnotationCreateData) *AnnotationCreateRequest { + this := AnnotationCreateRequest{} + this.Data = data + return &this +} + +// NewAnnotationCreateRequestWithDefaults instantiates a new AnnotationCreateRequest 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 NewAnnotationCreateRequestWithDefaults() *AnnotationCreateRequest { + this := AnnotationCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *AnnotationCreateRequest) GetData() AnnotationCreateData { + if o == nil { + var ret AnnotationCreateData + 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 *AnnotationCreateRequest) GetDataOk() (*AnnotationCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *AnnotationCreateRequest) SetData(v AnnotationCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AnnotationCreateRequest) 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 *AnnotationCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *AnnotationCreateData `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_annotation_data.go b/api/datadogV2/model_annotation_data.go new file mode 100644 index 00000000000..5c9e0681424 --- /dev/null +++ b/api/datadogV2/model_annotation_data.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AnnotationData A single annotation resource. +type AnnotationData struct { + // Attributes of an annotation returned in a response. + Attributes AnnotationAttributes `json:"attributes"` + // Unique identifier of the annotation. + Id uuid.UUID `json:"id"` + // Annotation resource type. + Type AnnotationType `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:"-"` +} + +// NewAnnotationData instantiates a new AnnotationData 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 NewAnnotationData(attributes AnnotationAttributes, id uuid.UUID, typeVar AnnotationType) *AnnotationData { + this := AnnotationData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewAnnotationDataWithDefaults instantiates a new AnnotationData 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 NewAnnotationDataWithDefaults() *AnnotationData { + this := AnnotationData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *AnnotationData) GetAttributes() AnnotationAttributes { + if o == nil { + var ret AnnotationAttributes + 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 *AnnotationData) GetAttributesOk() (*AnnotationAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *AnnotationData) SetAttributes(v AnnotationAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *AnnotationData) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + 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 *AnnotationData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *AnnotationData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *AnnotationData) GetType() AnnotationType { + if o == nil { + var ret AnnotationType + 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 *AnnotationData) GetTypeOk() (*AnnotationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AnnotationData) SetType(v AnnotationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AnnotationData) 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 *AnnotationData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *AnnotationAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *AnnotationType `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_annotation_in_page.go b/api/datadogV2/model_annotation_in_page.go new file mode 100644 index 00000000000..27a21e5fcb2 --- /dev/null +++ b/api/datadogV2/model_annotation_in_page.go @@ -0,0 +1,444 @@ +// 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/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AnnotationInPage A flat annotation object as it appears within a page annotations response. +type AnnotationInPage struct { + // Identifier of the user who created the annotation. + AuthorId string `json:"author_id"` + // Color used to render the annotation in the UI. + Color AnnotationColor `json:"color"` + // Creation time of the annotation in milliseconds since the Unix epoch. + CreatedAt int64 `json:"created_at"` + // User-defined text attached to the annotation. + Description string `json:"description"` + // End time of the annotation in milliseconds since the Unix epoch. Null for `pointInTime` annotations. + EndTime datadog.NullableInt64 `json:"end_time"` + // Unique identifier of the annotation. + Id uuid.UUID `json:"id"` + // Last modification time of the annotation in milliseconds since the Unix epoch. + ModifiedAt int64 `json:"modified_at"` + // ID of the page the annotation belongs to, prefixed with the page type and joined by a colon + // (for example, `dashboard:abc-def-xyz` or `notebook:1234567890`). + PageId string `json:"page_id"` + // Start time of the annotation in milliseconds since the Unix epoch. + StartTime int64 `json:"start_time"` + // Kind of annotation. `pointInTime` annotations mark a single moment in time, + // while `timeRegion` annotations span a window of time and require an `end_time`. + Type AnnotationKind `json:"type"` + // IDs of widgets the annotation is associated with. When empty or omitted, the annotation applies to the whole page. + WidgetIds []string `json:"widget_ids,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:"-"` +} + +// NewAnnotationInPage instantiates a new AnnotationInPage 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 NewAnnotationInPage(authorId string, color AnnotationColor, createdAt int64, description string, endTime datadog.NullableInt64, id uuid.UUID, modifiedAt int64, pageId string, startTime int64, typeVar AnnotationKind) *AnnotationInPage { + this := AnnotationInPage{} + this.AuthorId = authorId + this.Color = color + this.CreatedAt = createdAt + this.Description = description + this.EndTime = endTime + this.Id = id + this.ModifiedAt = modifiedAt + this.PageId = pageId + this.StartTime = startTime + this.Type = typeVar + return &this +} + +// NewAnnotationInPageWithDefaults instantiates a new AnnotationInPage 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 NewAnnotationInPageWithDefaults() *AnnotationInPage { + this := AnnotationInPage{} + return &this +} + +// GetAuthorId returns the AuthorId field value. +func (o *AnnotationInPage) GetAuthorId() string { + if o == nil { + var ret string + return ret + } + return o.AuthorId +} + +// GetAuthorIdOk returns a tuple with the AuthorId field value +// and a boolean to check if the value has been set. +func (o *AnnotationInPage) GetAuthorIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AuthorId, true +} + +// SetAuthorId sets field value. +func (o *AnnotationInPage) SetAuthorId(v string) { + o.AuthorId = v +} + +// GetColor returns the Color field value. +func (o *AnnotationInPage) GetColor() AnnotationColor { + if o == nil { + var ret AnnotationColor + return ret + } + return o.Color +} + +// GetColorOk returns a tuple with the Color field value +// and a boolean to check if the value has been set. +func (o *AnnotationInPage) GetColorOk() (*AnnotationColor, bool) { + if o == nil { + return nil, false + } + return &o.Color, true +} + +// SetColor sets field value. +func (o *AnnotationInPage) SetColor(v AnnotationColor) { + o.Color = v +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *AnnotationInPage) GetCreatedAt() int64 { + if o == nil { + var ret int64 + 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 *AnnotationInPage) GetCreatedAtOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *AnnotationInPage) SetCreatedAt(v int64) { + o.CreatedAt = v +} + +// GetDescription returns the Description field value. +func (o *AnnotationInPage) 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 *AnnotationInPage) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *AnnotationInPage) SetDescription(v string) { + o.Description = v +} + +// GetEndTime returns the EndTime field value. +// If the value is explicit nil, the zero value for int64 will be returned. +func (o *AnnotationInPage) GetEndTime() int64 { + if o == nil || o.EndTime.Get() == nil { + var ret int64 + return ret + } + return *o.EndTime.Get() +} + +// GetEndTimeOk returns a tuple with the EndTime field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *AnnotationInPage) GetEndTimeOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.EndTime.Get(), o.EndTime.IsSet() +} + +// SetEndTime sets field value. +func (o *AnnotationInPage) SetEndTime(v int64) { + o.EndTime.Set(&v) +} + +// GetId returns the Id field value. +func (o *AnnotationInPage) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + 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 *AnnotationInPage) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *AnnotationInPage) SetId(v uuid.UUID) { + o.Id = v +} + +// GetModifiedAt returns the ModifiedAt field value. +func (o *AnnotationInPage) GetModifiedAt() int64 { + if o == nil { + var ret int64 + return ret + } + return o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value +// and a boolean to check if the value has been set. +func (o *AnnotationInPage) GetModifiedAtOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.ModifiedAt, true +} + +// SetModifiedAt sets field value. +func (o *AnnotationInPage) SetModifiedAt(v int64) { + o.ModifiedAt = v +} + +// GetPageId returns the PageId field value. +func (o *AnnotationInPage) GetPageId() string { + if o == nil { + var ret string + return ret + } + return o.PageId +} + +// GetPageIdOk returns a tuple with the PageId field value +// and a boolean to check if the value has been set. +func (o *AnnotationInPage) GetPageIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PageId, true +} + +// SetPageId sets field value. +func (o *AnnotationInPage) SetPageId(v string) { + o.PageId = v +} + +// GetStartTime returns the StartTime field value. +func (o *AnnotationInPage) GetStartTime() int64 { + if o == nil { + var ret int64 + return ret + } + return o.StartTime +} + +// GetStartTimeOk returns a tuple with the StartTime field value +// and a boolean to check if the value has been set. +func (o *AnnotationInPage) GetStartTimeOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.StartTime, true +} + +// SetStartTime sets field value. +func (o *AnnotationInPage) SetStartTime(v int64) { + o.StartTime = v +} + +// GetType returns the Type field value. +func (o *AnnotationInPage) GetType() AnnotationKind { + if o == nil { + var ret AnnotationKind + 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 *AnnotationInPage) GetTypeOk() (*AnnotationKind, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AnnotationInPage) SetType(v AnnotationKind) { + o.Type = v +} + +// GetWidgetIds returns the WidgetIds field value if set, zero value otherwise. +func (o *AnnotationInPage) GetWidgetIds() []string { + if o == nil || o.WidgetIds == nil { + var ret []string + return ret + } + return o.WidgetIds +} + +// GetWidgetIdsOk returns a tuple with the WidgetIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AnnotationInPage) GetWidgetIdsOk() (*[]string, bool) { + if o == nil || o.WidgetIds == nil { + return nil, false + } + return &o.WidgetIds, true +} + +// HasWidgetIds returns a boolean if a field has been set. +func (o *AnnotationInPage) HasWidgetIds() bool { + return o != nil && o.WidgetIds != nil +} + +// SetWidgetIds gets a reference to the given []string and assigns it to the WidgetIds field. +func (o *AnnotationInPage) SetWidgetIds(v []string) { + o.WidgetIds = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AnnotationInPage) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["author_id"] = o.AuthorId + toSerialize["color"] = o.Color + toSerialize["created_at"] = o.CreatedAt + toSerialize["description"] = o.Description + toSerialize["end_time"] = o.EndTime.Get() + toSerialize["id"] = o.Id + toSerialize["modified_at"] = o.ModifiedAt + toSerialize["page_id"] = o.PageId + toSerialize["start_time"] = o.StartTime + toSerialize["type"] = o.Type + if o.WidgetIds != nil { + toSerialize["widget_ids"] = o.WidgetIds + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AnnotationInPage) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AuthorId *string `json:"author_id"` + Color *AnnotationColor `json:"color"` + CreatedAt *int64 `json:"created_at"` + Description *string `json:"description"` + EndTime datadog.NullableInt64 `json:"end_time"` + Id *uuid.UUID `json:"id"` + ModifiedAt *int64 `json:"modified_at"` + PageId *string `json:"page_id"` + StartTime *int64 `json:"start_time"` + Type *AnnotationKind `json:"type"` + WidgetIds []string `json:"widget_ids,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AuthorId == nil { + return fmt.Errorf("required field author_id missing") + } + if all.Color == nil { + return fmt.Errorf("required field color missing") + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if !all.EndTime.IsSet() { + return fmt.Errorf("required field end_time missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.ModifiedAt == nil { + return fmt.Errorf("required field modified_at missing") + } + if all.PageId == nil { + return fmt.Errorf("required field page_id missing") + } + if all.StartTime == nil { + return fmt.Errorf("required field start_time 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{"author_id", "color", "created_at", "description", "end_time", "id", "modified_at", "page_id", "start_time", "type", "widget_ids"}) + } else { + return err + } + + hasInvalidField := false + o.AuthorId = *all.AuthorId + if !all.Color.IsValid() { + hasInvalidField = true + } else { + o.Color = *all.Color + } + o.CreatedAt = *all.CreatedAt + o.Description = *all.Description + o.EndTime = all.EndTime + o.Id = *all.Id + o.ModifiedAt = *all.ModifiedAt + o.PageId = *all.PageId + o.StartTime = *all.StartTime + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.WidgetIds = all.WidgetIds + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_annotation_kind.go b/api/datadogV2/model_annotation_kind.go new file mode 100644 index 00000000000..8b5f25441e0 --- /dev/null +++ b/api/datadogV2/model_annotation_kind.go @@ -0,0 +1,67 @@ +// 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" +) + +// AnnotationKind Kind of annotation. `pointInTime` annotations mark a single moment in time, +// while `timeRegion` annotations span a window of time and require an `end_time`. +type AnnotationKind string + +// List of AnnotationKind. +const ( + ANNOTATIONKIND_POINT_IN_TIME AnnotationKind = "pointInTime" + ANNOTATIONKIND_TIME_REGION AnnotationKind = "timeRegion" +) + +var allowedAnnotationKindEnumValues = []AnnotationKind{ + ANNOTATIONKIND_POINT_IN_TIME, + ANNOTATIONKIND_TIME_REGION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AnnotationKind) GetAllowedValues() []AnnotationKind { + return allowedAnnotationKindEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AnnotationKind) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AnnotationKind(value) + return nil +} + +// NewAnnotationKindFromValue returns a pointer to a valid AnnotationKind +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAnnotationKindFromValue(v string) (*AnnotationKind, error) { + ev := AnnotationKind(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AnnotationKind: valid values are %v", v, allowedAnnotationKindEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AnnotationKind) IsValid() bool { + for _, existing := range allowedAnnotationKindEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AnnotationKind value. +func (v AnnotationKind) Ptr() *AnnotationKind { + return &v +} diff --git a/api/datadogV2/model_annotation_response.go b/api/datadogV2/model_annotation_response.go new file mode 100644 index 00000000000..a163af9267d --- /dev/null +++ b/api/datadogV2/model_annotation_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" +) + +// AnnotationResponse Response containing a single annotation. +type AnnotationResponse struct { + // A single annotation resource. + Data AnnotationData `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:"-"` +} + +// NewAnnotationResponse instantiates a new AnnotationResponse 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 NewAnnotationResponse(data AnnotationData) *AnnotationResponse { + this := AnnotationResponse{} + this.Data = data + return &this +} + +// NewAnnotationResponseWithDefaults instantiates a new AnnotationResponse 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 NewAnnotationResponseWithDefaults() *AnnotationResponse { + this := AnnotationResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *AnnotationResponse) GetData() AnnotationData { + if o == nil { + var ret AnnotationData + 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 *AnnotationResponse) GetDataOk() (*AnnotationData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *AnnotationResponse) SetData(v AnnotationData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AnnotationResponse) 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 *AnnotationResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *AnnotationData `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_annotation_type.go b/api/datadogV2/model_annotation_type.go new file mode 100644 index 00000000000..be4adb6c0eb --- /dev/null +++ b/api/datadogV2/model_annotation_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" +) + +// AnnotationType Annotation resource type. +type AnnotationType string + +// List of AnnotationType. +const ( + ANNOTATIONTYPE_ANNOTATION AnnotationType = "annotation" +) + +var allowedAnnotationTypeEnumValues = []AnnotationType{ + ANNOTATIONTYPE_ANNOTATION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AnnotationType) GetAllowedValues() []AnnotationType { + return allowedAnnotationTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AnnotationType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AnnotationType(value) + return nil +} + +// NewAnnotationTypeFromValue returns a pointer to a valid AnnotationType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAnnotationTypeFromValue(v string) (*AnnotationType, error) { + ev := AnnotationType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AnnotationType: valid values are %v", v, allowedAnnotationTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AnnotationType) IsValid() bool { + for _, existing := range allowedAnnotationTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AnnotationType value. +func (v AnnotationType) Ptr() *AnnotationType { + return &v +} diff --git a/api/datadogV2/model_annotation_update_data.go b/api/datadogV2/model_annotation_update_data.go new file mode 100644 index 00000000000..f4c4dea22c2 --- /dev/null +++ b/api/datadogV2/model_annotation_update_data.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AnnotationUpdateData Data for updating an annotation. +type AnnotationUpdateData struct { + // Attributes for creating or updating an annotation. + Attributes AnnotationCreateAttributes `json:"attributes"` + // Unique identifier of the annotation to update. + Id uuid.UUID `json:"id"` + // Annotation resource type. + Type AnnotationType `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:"-"` +} + +// NewAnnotationUpdateData instantiates a new AnnotationUpdateData 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 NewAnnotationUpdateData(attributes AnnotationCreateAttributes, id uuid.UUID, typeVar AnnotationType) *AnnotationUpdateData { + this := AnnotationUpdateData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewAnnotationUpdateDataWithDefaults instantiates a new AnnotationUpdateData 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 NewAnnotationUpdateDataWithDefaults() *AnnotationUpdateData { + this := AnnotationUpdateData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *AnnotationUpdateData) GetAttributes() AnnotationCreateAttributes { + if o == nil { + var ret AnnotationCreateAttributes + 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 *AnnotationUpdateData) GetAttributesOk() (*AnnotationCreateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *AnnotationUpdateData) SetAttributes(v AnnotationCreateAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *AnnotationUpdateData) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + 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 *AnnotationUpdateData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *AnnotationUpdateData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *AnnotationUpdateData) GetType() AnnotationType { + if o == nil { + var ret AnnotationType + 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 *AnnotationUpdateData) GetTypeOk() (*AnnotationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AnnotationUpdateData) SetType(v AnnotationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AnnotationUpdateData) 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 *AnnotationUpdateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *AnnotationCreateAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *AnnotationType `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_annotation_update_request.go b/api/datadogV2/model_annotation_update_request.go new file mode 100644 index 00000000000..8e8d8e61268 --- /dev/null +++ b/api/datadogV2/model_annotation_update_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" +) + +// AnnotationUpdateRequest Request body for updating an annotation. +type AnnotationUpdateRequest struct { + // Data for updating an annotation. + Data AnnotationUpdateData `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:"-"` +} + +// NewAnnotationUpdateRequest instantiates a new AnnotationUpdateRequest 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 NewAnnotationUpdateRequest(data AnnotationUpdateData) *AnnotationUpdateRequest { + this := AnnotationUpdateRequest{} + this.Data = data + return &this +} + +// NewAnnotationUpdateRequestWithDefaults instantiates a new AnnotationUpdateRequest 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 NewAnnotationUpdateRequestWithDefaults() *AnnotationUpdateRequest { + this := AnnotationUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *AnnotationUpdateRequest) GetData() AnnotationUpdateData { + if o == nil { + var ret AnnotationUpdateData + 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 *AnnotationUpdateRequest) GetDataOk() (*AnnotationUpdateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *AnnotationUpdateRequest) SetData(v AnnotationUpdateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AnnotationUpdateRequest) 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 *AnnotationUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *AnnotationUpdateData `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_annotations_response.go b/api/datadogV2/model_annotations_response.go new file mode 100644 index 00000000000..cb8e4198177 --- /dev/null +++ b/api/datadogV2/model_annotations_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" +) + +// AnnotationsResponse Response containing a list of annotations. +type AnnotationsResponse struct { + // List of annotation resources. + Data []AnnotationData `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:"-"` +} + +// NewAnnotationsResponse instantiates a new AnnotationsResponse 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 NewAnnotationsResponse(data []AnnotationData) *AnnotationsResponse { + this := AnnotationsResponse{} + this.Data = data + return &this +} + +// NewAnnotationsResponseWithDefaults instantiates a new AnnotationsResponse 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 NewAnnotationsResponseWithDefaults() *AnnotationsResponse { + this := AnnotationsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *AnnotationsResponse) GetData() []AnnotationData { + if o == nil { + var ret []AnnotationData + 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 *AnnotationsResponse) GetDataOk() (*[]AnnotationData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *AnnotationsResponse) SetData(v []AnnotationData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AnnotationsResponse) 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 *AnnotationsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]AnnotationData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_page_annotations_attributes.go b/api/datadogV2/model_page_annotations_attributes.go new file mode 100644 index 00000000000..c940162a8c4 --- /dev/null +++ b/api/datadogV2/model_page_annotations_attributes.go @@ -0,0 +1,167 @@ +// 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/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PageAnnotationsAttributes Attributes of the annotations on a page. +type PageAnnotationsAttributes struct { + // Map of annotation UUID to annotation object, keyed by annotation ID. + Annotations map[string]AnnotationInPage `json:"annotations"` + // List of annotation IDs that apply to the entire page rather than a specific widget. + GlobalAnnotations []uuid.UUID `json:"global_annotations"` + // Map from widget ID to the list of annotation IDs displayed on that widget. + WidgetMapping map[string][]uuid.UUID `json:"widget_mapping"` + // 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:"-"` +} + +// NewPageAnnotationsAttributes instantiates a new PageAnnotationsAttributes 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 NewPageAnnotationsAttributes(annotations map[string]AnnotationInPage, globalAnnotations []uuid.UUID, widgetMapping map[string][]uuid.UUID) *PageAnnotationsAttributes { + this := PageAnnotationsAttributes{} + this.Annotations = annotations + this.GlobalAnnotations = globalAnnotations + this.WidgetMapping = widgetMapping + return &this +} + +// NewPageAnnotationsAttributesWithDefaults instantiates a new PageAnnotationsAttributes 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 NewPageAnnotationsAttributesWithDefaults() *PageAnnotationsAttributes { + this := PageAnnotationsAttributes{} + return &this +} + +// GetAnnotations returns the Annotations field value. +func (o *PageAnnotationsAttributes) GetAnnotations() map[string]AnnotationInPage { + if o == nil { + var ret map[string]AnnotationInPage + return ret + } + return o.Annotations +} + +// GetAnnotationsOk returns a tuple with the Annotations field value +// and a boolean to check if the value has been set. +func (o *PageAnnotationsAttributes) GetAnnotationsOk() (*map[string]AnnotationInPage, bool) { + if o == nil { + return nil, false + } + return &o.Annotations, true +} + +// SetAnnotations sets field value. +func (o *PageAnnotationsAttributes) SetAnnotations(v map[string]AnnotationInPage) { + o.Annotations = v +} + +// GetGlobalAnnotations returns the GlobalAnnotations field value. +func (o *PageAnnotationsAttributes) GetGlobalAnnotations() []uuid.UUID { + if o == nil { + var ret []uuid.UUID + return ret + } + return o.GlobalAnnotations +} + +// GetGlobalAnnotationsOk returns a tuple with the GlobalAnnotations field value +// and a boolean to check if the value has been set. +func (o *PageAnnotationsAttributes) GetGlobalAnnotationsOk() (*[]uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.GlobalAnnotations, true +} + +// SetGlobalAnnotations sets field value. +func (o *PageAnnotationsAttributes) SetGlobalAnnotations(v []uuid.UUID) { + o.GlobalAnnotations = v +} + +// GetWidgetMapping returns the WidgetMapping field value. +func (o *PageAnnotationsAttributes) GetWidgetMapping() map[string][]uuid.UUID { + if o == nil { + var ret map[string][]uuid.UUID + return ret + } + return o.WidgetMapping +} + +// GetWidgetMappingOk returns a tuple with the WidgetMapping field value +// and a boolean to check if the value has been set. +func (o *PageAnnotationsAttributes) GetWidgetMappingOk() (*map[string][]uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.WidgetMapping, true +} + +// SetWidgetMapping sets field value. +func (o *PageAnnotationsAttributes) SetWidgetMapping(v map[string][]uuid.UUID) { + o.WidgetMapping = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PageAnnotationsAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["annotations"] = o.Annotations + toSerialize["global_annotations"] = o.GlobalAnnotations + toSerialize["widget_mapping"] = o.WidgetMapping + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PageAnnotationsAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Annotations *map[string]AnnotationInPage `json:"annotations"` + GlobalAnnotations *[]uuid.UUID `json:"global_annotations"` + WidgetMapping *map[string][]uuid.UUID `json:"widget_mapping"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Annotations == nil { + return fmt.Errorf("required field annotations missing") + } + if all.GlobalAnnotations == nil { + return fmt.Errorf("required field global_annotations missing") + } + if all.WidgetMapping == nil { + return fmt.Errorf("required field widget_mapping missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"annotations", "global_annotations", "widget_mapping"}) + } else { + return err + } + o.Annotations = *all.Annotations + o.GlobalAnnotations = *all.GlobalAnnotations + o.WidgetMapping = *all.WidgetMapping + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_page_annotations_data.go b/api/datadogV2/model_page_annotations_data.go new file mode 100644 index 00000000000..833e199f46b --- /dev/null +++ b/api/datadogV2/model_page_annotations_data.go @@ -0,0 +1,179 @@ +// 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" +) + +// PageAnnotationsData Annotations grouped by widget for a single page. +type PageAnnotationsData struct { + // Attributes of the annotations on a page. + Attributes PageAnnotationsAttributes `json:"attributes"` + // ID of the page, prefixed with the page type and joined by a colon + // (for example, `dashboard:abc-def-xyz` or `notebook:1234567890`). + Id string `json:"id"` + // Page annotations resource type. + Type PageAnnotationsType `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:"-"` +} + +// NewPageAnnotationsData instantiates a new PageAnnotationsData 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 NewPageAnnotationsData(attributes PageAnnotationsAttributes, id string, typeVar PageAnnotationsType) *PageAnnotationsData { + this := PageAnnotationsData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewPageAnnotationsDataWithDefaults instantiates a new PageAnnotationsData 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 NewPageAnnotationsDataWithDefaults() *PageAnnotationsData { + this := PageAnnotationsData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *PageAnnotationsData) GetAttributes() PageAnnotationsAttributes { + if o == nil { + var ret PageAnnotationsAttributes + 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 *PageAnnotationsData) GetAttributesOk() (*PageAnnotationsAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *PageAnnotationsData) SetAttributes(v PageAnnotationsAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *PageAnnotationsData) 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 *PageAnnotationsData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *PageAnnotationsData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *PageAnnotationsData) GetType() PageAnnotationsType { + if o == nil { + var ret PageAnnotationsType + 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 *PageAnnotationsData) GetTypeOk() (*PageAnnotationsType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PageAnnotationsData) SetType(v PageAnnotationsType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PageAnnotationsData) 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 *PageAnnotationsData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *PageAnnotationsAttributes `json:"attributes"` + Id *string `json:"id"` + Type *PageAnnotationsType `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_page_annotations_response.go b/api/datadogV2/model_page_annotations_response.go new file mode 100644 index 00000000000..5786db79b33 --- /dev/null +++ b/api/datadogV2/model_page_annotations_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" +) + +// PageAnnotationsResponse Response containing all annotations on a page, grouped by widget. +type PageAnnotationsResponse struct { + // Annotations grouped by widget for a single page. + Data PageAnnotationsData `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:"-"` +} + +// NewPageAnnotationsResponse instantiates a new PageAnnotationsResponse 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 NewPageAnnotationsResponse(data PageAnnotationsData) *PageAnnotationsResponse { + this := PageAnnotationsResponse{} + this.Data = data + return &this +} + +// NewPageAnnotationsResponseWithDefaults instantiates a new PageAnnotationsResponse 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 NewPageAnnotationsResponseWithDefaults() *PageAnnotationsResponse { + this := PageAnnotationsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *PageAnnotationsResponse) GetData() PageAnnotationsData { + if o == nil { + var ret PageAnnotationsData + 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 *PageAnnotationsResponse) GetDataOk() (*PageAnnotationsData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *PageAnnotationsResponse) SetData(v PageAnnotationsData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PageAnnotationsResponse) 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 *PageAnnotationsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PageAnnotationsData `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_page_annotations_type.go b/api/datadogV2/model_page_annotations_type.go new file mode 100644 index 00000000000..a021d275a13 --- /dev/null +++ b/api/datadogV2/model_page_annotations_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" +) + +// PageAnnotationsType Page annotations resource type. +type PageAnnotationsType string + +// List of PageAnnotationsType. +const ( + PAGEANNOTATIONSTYPE_PAGE_ANNOTATIONS PageAnnotationsType = "page_annotations" +) + +var allowedPageAnnotationsTypeEnumValues = []PageAnnotationsType{ + PAGEANNOTATIONSTYPE_PAGE_ANNOTATIONS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *PageAnnotationsType) GetAllowedValues() []PageAnnotationsType { + return allowedPageAnnotationsTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *PageAnnotationsType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = PageAnnotationsType(value) + return nil +} + +// NewPageAnnotationsTypeFromValue returns a pointer to a valid PageAnnotationsType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewPageAnnotationsTypeFromValue(v string) (*PageAnnotationsType, error) { + ev := PageAnnotationsType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for PageAnnotationsType: valid values are %v", v, allowedPageAnnotationsTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v PageAnnotationsType) IsValid() bool { + for _, existing := range allowedPageAnnotationsTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to PageAnnotationsType value. +func (v PageAnnotationsType) Ptr() *PageAnnotationsType { + return &v +} diff --git a/examples/v2/annotations/CreateAnnotation.go b/examples/v2/annotations/CreateAnnotation.go new file mode 100644 index 00000000000..e234a6acbbb --- /dev/null +++ b/examples/v2/annotations/CreateAnnotation.go @@ -0,0 +1,46 @@ +// Create an annotation 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.AnnotationCreateRequest{ + Data: datadogV2.AnnotationCreateData{ + Attributes: datadogV2.AnnotationCreateAttributes{ + Color: datadogV2.ANNOTATIONCOLOR_BLUE, + Description: "Deployed v2.3.1 to production.", + EndTime: *datadog.NewNullableInt64(datadog.PtrInt64(1704070800000)), + PageId: "dashboard:abc-def-xyz", + StartTime: 1704067200000, + Type: datadogV2.ANNOTATIONKIND_POINT_IN_TIME, + WidgetIds: []string{ + "1234567890", + }, + }, + Type: datadogV2.ANNOTATIONTYPE_ANNOTATION, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateAnnotation", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewAnnotationsApi(apiClient) + resp, r, err := api.CreateAnnotation(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `AnnotationsApi.CreateAnnotation`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `AnnotationsApi.CreateAnnotation`:\n%s\n", responseContent) +} diff --git a/examples/v2/annotations/DeleteAnnotation.go b/examples/v2/annotations/DeleteAnnotation.go new file mode 100644 index 00000000000..2b491182e33 --- /dev/null +++ b/examples/v2/annotations/DeleteAnnotation.go @@ -0,0 +1,27 @@ +// Delete an annotation returns "OK" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.DeleteAnnotation", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewAnnotationsApi(apiClient) + r, err := api.DeleteAnnotation(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `AnnotationsApi.DeleteAnnotation`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/annotations/GetPageAnnotations.go b/examples/v2/annotations/GetPageAnnotations.go new file mode 100644 index 00000000000..516f6529554 --- /dev/null +++ b/examples/v2/annotations/GetPageAnnotations.go @@ -0,0 +1,30 @@ +// Get annotations for a page returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetPageAnnotations", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewAnnotationsApi(apiClient) + resp, r, err := api.GetPageAnnotations(ctx, "page_id", 9223372036854775807, 9223372036854775807) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `AnnotationsApi.GetPageAnnotations`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `AnnotationsApi.GetPageAnnotations`:\n%s\n", responseContent) +} diff --git a/examples/v2/annotations/ListAnnotations.go b/examples/v2/annotations/ListAnnotations.go new file mode 100644 index 00000000000..b4d21ed4366 --- /dev/null +++ b/examples/v2/annotations/ListAnnotations.go @@ -0,0 +1,30 @@ +// List annotations returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListAnnotations", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewAnnotationsApi(apiClient) + resp, r, err := api.ListAnnotations(ctx, "page_id", 9223372036854775807, 9223372036854775807, *datadogV2.NewListAnnotationsOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `AnnotationsApi.ListAnnotations`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `AnnotationsApi.ListAnnotations`:\n%s\n", responseContent) +} diff --git a/examples/v2/annotations/UpdateAnnotation.go b/examples/v2/annotations/UpdateAnnotation.go new file mode 100644 index 00000000000..5c902023d79 --- /dev/null +++ b/examples/v2/annotations/UpdateAnnotation.go @@ -0,0 +1,48 @@ +// Update an annotation 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" + "github.com/google/uuid" +) + +func main() { + body := datadogV2.AnnotationUpdateRequest{ + Data: datadogV2.AnnotationUpdateData{ + Attributes: datadogV2.AnnotationCreateAttributes{ + Color: datadogV2.ANNOTATIONCOLOR_BLUE, + Description: "Deployed v2.3.1 to production.", + EndTime: *datadog.NewNullableInt64(datadog.PtrInt64(1704070800000)), + PageId: "dashboard:abc-def-xyz", + StartTime: 1704067200000, + Type: datadogV2.ANNOTATIONKIND_POINT_IN_TIME, + WidgetIds: []string{ + "1234567890", + }, + }, + Id: uuid.MustParse("00000000-0000-0000-0000-000000000000"), + Type: datadogV2.ANNOTATIONTYPE_ANNOTATION, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpdateAnnotation", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewAnnotationsApi(apiClient) + resp, r, err := api.UpdateAnnotation(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `AnnotationsApi.UpdateAnnotation`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `AnnotationsApi.UpdateAnnotation`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 2db1e0d86c6..a16d9551ec3 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -49,6 +49,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "ActionsDatastoresApi": reflect.ValueOf(datadogV2.NewActionsDatastoresApi), "ActionConnectionApi": reflect.ValueOf(datadogV2.NewActionConnectionApi), "AgentlessScanningApi": reflect.ValueOf(datadogV2.NewAgentlessScanningApi), + "AnnotationsApi": reflect.ValueOf(datadogV2.NewAnnotationsApi), "UsersApi": reflect.ValueOf(datadogV2.NewUsersApi), "KeyManagementApi": reflect.ValueOf(datadogV2.NewKeyManagementApi), "APIManagementApi": reflect.ValueOf(datadogV2.NewAPIManagementApi), diff --git a/tests/scenarios/features/v2/annotations.feature b/tests/scenarios/features/v2/annotations.feature new file mode 100644 index 00000000000..5843174812d --- /dev/null +++ b/tests/scenarios/features/v2/annotations.feature @@ -0,0 +1,116 @@ +@endpoint(annotations) @endpoint(annotations-v2) +Feature: Annotations + Add annotations to dashboards and notebooks to mark events such as + deployments, incidents, or other notable moments in time. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "Annotations" API + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: Create an annotation returns "Bad Request" response + Given operation "CreateAnnotation" enabled + And new "CreateAnnotation" request + And body with value {"data": {"attributes": {"color": "blue", "description": "Deployed v2.3.1 to production.", "end_time": 1704070800000, "page_id": "dashboard:abc-def-xyz", "start_time": 1704067200000, "type": "pointInTime", "widget_ids": ["1234567890"]}, "type": "annotation"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: Create an annotation returns "OK" response + Given operation "CreateAnnotation" enabled + And new "CreateAnnotation" request + And body with value {"data": {"attributes": {"color": "blue", "description": "Deployed v2.3.1 to production.", "end_time": 1704070800000, "page_id": "dashboard:abc-def-xyz", "start_time": 1704067200000, "type": "pointInTime", "widget_ids": ["1234567890"]}, "type": "annotation"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: Delete an annotation returns "Bad Request" response + Given operation "DeleteAnnotation" enabled + And new "DeleteAnnotation" request + And request contains "annotation_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: Delete an annotation returns "No Content" response + Given operation "DeleteAnnotation" enabled + And new "DeleteAnnotation" request + And request contains "annotation_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: Delete an annotation returns "OK" response + Given operation "DeleteAnnotation" enabled + And new "DeleteAnnotation" request + And request contains "annotation_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: Get annotations for a page returns "Bad Request" response + Given operation "GetPageAnnotations" enabled + And new "GetPageAnnotations" request + And request contains "page_id" parameter from "REPLACE.ME" + And request contains "start_time" parameter from "REPLACE.ME" + And request contains "end_time" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: Get annotations for a page returns "OK" response + Given operation "GetPageAnnotations" enabled + And new "GetPageAnnotations" request + And request contains "page_id" parameter from "REPLACE.ME" + And request contains "start_time" parameter from "REPLACE.ME" + And request contains "end_time" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: List annotations returns "Bad Request" response + Given operation "ListAnnotations" enabled + And new "ListAnnotations" request + And request contains "page_id" parameter from "REPLACE.ME" + And request contains "start_time" parameter from "REPLACE.ME" + And request contains "end_time" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: List annotations returns "OK" response + Given operation "ListAnnotations" enabled + And new "ListAnnotations" request + And request contains "page_id" parameter from "REPLACE.ME" + And request contains "start_time" parameter from "REPLACE.ME" + And request contains "end_time" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: Update an annotation returns "Bad Request" response + Given operation "UpdateAnnotation" enabled + And new "UpdateAnnotation" request + And request contains "annotation_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"color": "blue", "description": "Deployed v2.3.1 to production.", "end_time": 1704070800000, "page_id": "dashboard:abc-def-xyz", "start_time": 1704067200000, "type": "pointInTime", "widget_ids": ["1234567890"]}, "id": "00000000-0000-0000-0000-000000000000", "type": "annotation"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: Update an annotation returns "Not Found" response + Given operation "UpdateAnnotation" enabled + And new "UpdateAnnotation" request + And request contains "annotation_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"color": "blue", "description": "Deployed v2.3.1 to production.", "end_time": 1704070800000, "page_id": "dashboard:abc-def-xyz", "start_time": 1704067200000, "type": "pointInTime", "widget_ids": ["1234567890"]}, "id": "00000000-0000-0000-0000-000000000000", "type": "annotation"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/dataviz-advanced-analytics + Scenario: Update an annotation returns "OK" response + Given operation "UpdateAnnotation" enabled + And new "UpdateAnnotation" request + And request contains "annotation_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"color": "blue", "description": "Deployed v2.3.1 to production.", "end_time": 1704070800000, "page_id": "dashboard:abc-def-xyz", "start_time": 1704067200000, "type": "pointInTime", "widget_ids": ["1234567890"]}, "id": "00000000-0000-0000-0000-000000000000", "type": "annotation"}} + 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 02753f1a80a..8010f680a02 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -411,6 +411,43 @@ "type": "safe" } }, + "ListAnnotations": { + "tag": "Annotations", + "undo": { + "type": "safe" + } + }, + "CreateAnnotation": { + "tag": "Annotations", + "undo": { + "operationId": "DeleteAnnotation", + "parameters": [ + { + "name": "annotation_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "GetPageAnnotations": { + "tag": "Annotations", + "undo": { + "type": "safe" + } + }, + "DeleteAnnotation": { + "tag": "Annotations", + "undo": { + "type": "idempotent" + } + }, + "UpdateAnnotation": { + "tag": "Annotations", + "undo": { + "type": "idempotent" + } + }, "AnonymizeUsers": { "tag": "Users", "undo": {