diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 731b9e5160..6bfc10500d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -24622,6 +24622,184 @@ components: - findings - project type: object + CreateSnapshotAdditionalConfig: + description: Additional configuration options for snapshot creation. + properties: + template_variables: + $ref: "#/components/schemas/CreateSnapshotTemplateVariables" + timeseries_legend_type: + $ref: "#/components/schemas/CreateSnapshotTimeseriesLegendType" + timezone_offset_minutes: + description: Timezone offset in minutes from UTC. Positive values are west of UTC (for example, `300` for UTC-5). Use `0` for UTC. + example: 300 + format: int64 + type: integer + type: object + CreateSnapshotDataAttributesRequest: + description: Attributes for snapshot creation. + properties: + additional_config: + $ref: "#/components/schemas/CreateSnapshotAdditionalConfig" + end: + description: End of the time window for the snapshot, in milliseconds since Unix epoch. + example: 1692464800000 + format: int64 + type: integer + height: + description: The height of the rendered snapshot in pixels. + example: 185 + format: int64 + type: integer + is_authenticated: + description: Whether the snapshot requires authentication to view. Authenticated snapshots are scoped to the creating organization. + example: false + type: boolean + start: + description: Start of the time window for the snapshot, in milliseconds since Unix epoch. + example: 1692464000000 + format: int64 + type: integer + ttl: + $ref: "#/components/schemas/CreateSnapshotTTL" + widget_definition: + additionalProperties: {} + description: The widget definition to render as a snapshot. Must include a valid `type` field and non-empty `requests` array. + example: + requests: + - q: "avg:system.cpu.user{*}" + type: timeseries + type: object + width: + description: The width of the rendered snapshot in pixels. + example: 300 + format: int64 + type: integer + required: + - widget_definition + - start + - end + type: object + CreateSnapshotDataAttributesResponse: + description: Attributes of the created snapshot. + properties: + url: + description: The URL to access the rendered snapshot image. + example: https://app.datadoghq.com/api/v2/snapshot/view/public/60d/00000000-0000-0000-0000-000000000000/1692464400000-12345678-1234-5678-9abc-def123456789.png + type: string + required: + - url + type: object + CreateSnapshotDataRequest: + description: Data envelope for snapshot creation. + properties: + attributes: + $ref: "#/components/schemas/CreateSnapshotDataAttributesRequest" + type: + $ref: "#/components/schemas/CreateSnapshotType" + required: + - type + - attributes + type: object + CreateSnapshotDataResponse: + description: Data envelope for the snapshot creation response. + properties: + attributes: + $ref: "#/components/schemas/CreateSnapshotDataAttributesResponse" + id: + description: The unique identifier of the created snapshot. + example: 12345678-1234-5678-9abc-def123456789 + type: string + type: + $ref: "#/components/schemas/CreateSnapshotType" + required: + - id + - type + - attributes + type: object + CreateSnapshotRequest: + description: Request body for creating a graph snapshot. + properties: + data: + $ref: "#/components/schemas/CreateSnapshotDataRequest" + required: + - data + type: object + CreateSnapshotResponse: + description: Response body for a snapshot creation request. + properties: + data: + $ref: "#/components/schemas/CreateSnapshotDataResponse" + required: + - data + type: object + CreateSnapshotTTL: + description: The time-to-live for the snapshot. This value corresponds to storage lifecycle policies that automatically delete the snapshot after the specified period. + enum: + - 30d + - 60d + - 90d + - 1y + - 2y + - inf + example: 60d + type: string + x-enum-varnames: + - THIRTY_DAYS + - SIXTY_DAYS + - NINETY_DAYS + - ONE_YEAR + - TWO_YEARS + - INFINITE + CreateSnapshotTemplateVariable: + description: A template variable definition for snapshot rendering. + properties: + name: + description: The template variable name. + example: host + type: string + prefix: + description: The tag prefix associated with the template variable. For example, a prefix of `host` with a value of `web-server-1` scopes the snapshot to `host:web-server-1`. + example: host + type: string + values: + description: The list of scoped values for this template variable. + example: + - web-server-1 + - web-server-2 + items: + description: A single scoped value for the template variable. + type: string + type: array + required: + - name + - prefix + - values + type: object + CreateSnapshotTemplateVariables: + description: List of template variable definitions for snapshot rendering. + items: + $ref: "#/components/schemas/CreateSnapshotTemplateVariable" + type: array + CreateSnapshotTimeseriesLegendType: + description: The legend display type for timeseries widgets. A value of `none` hides the legend entirely; omitting the field lets the frontend choose automatically. + enum: + - compact + - expanded + - none + example: expanded + type: string + x-enum-varnames: + - COMPACT + - EXPANDED + - NONE + CreateSnapshotType: + description: The type identifier for snapshot creation resources. + enum: + - create_snapshot + example: create_snapshot + type: string + x-enum-varnames: + - CREATE_SNAPSHOT CreateStatusPageRequest: description: Request object for creating a status page. example: @@ -182746,6 +182924,63 @@ paths: x-unstable: |- **Note**: This endpoint is in public beta and it's subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/snapshot: + post: + description: Create a snapshot of a graph widget. The snapshot is rendered asynchronously; the returned URL can be polled until the image is ready. + operationId: CreateSnapshot + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreateSnapshotRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + url: https://app.datadoghq.com/api/v2/snapshot/view/public/60d/00000000-0000-0000-0000-000000000000/1692464400000-12345678-1234-5678-9abc-def123456789.png + id: 12345678-1234-5678-9abc-def123456789 + type: create_snapshot + schema: + $ref: "#/components/schemas/CreateSnapshotResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Create a graph snapshot + tags: + - Reporting and Sharing + 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/sourcemaps: delete: description: |- @@ -197019,6 +197254,9 @@ tags: dashboard on a recurring cadence and delivers it to a set of recipients over email, Slack, or Microsoft Teams. name: Report Schedules + - description: |- + The Reporting and Sharing endpoints allow you to create snapshots of graph widgets and other shareable resources. + name: Reporting and Sharing - description: |- A restriction policy defines the access control rules for a resource, mapping a set of relations (such as editor and viewer) to a set of allowed principals (such as roles, teams, or users). diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index e56164d879..5a0513cda1 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -648,6 +648,13 @@ datadog\_api\_client.v2.api.report\_schedules\_api module :members: :show-inheritance: +datadog\_api\_client.v2.api.reporting\_and\_sharing\_api module +--------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.api.reporting_and_sharing_api + :members: + :show-inheritance: + datadog\_api\_client.v2.api.restriction\_policies\_api module ------------------------------------------------------------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index a084de08b3..4d85881d22 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -9482,6 +9482,83 @@ datadog\_api\_client.v2.model.create\_service\_now\_ticket\_request\_data\_relat :members: :show-inheritance: +datadog\_api\_client.v2.model.create\_snapshot\_additional\_config module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_additional_config + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_snapshot\_data\_attributes\_request module +-------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_data_attributes_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_snapshot\_data\_attributes\_response module +--------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_data_attributes_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_snapshot\_data\_request module +-------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_data_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_snapshot\_data\_response module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_data_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_snapshot\_request module +-------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_snapshot\_response module +--------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_snapshot\_template\_variable module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_template_variable + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_snapshot\_timeseries\_legend\_type module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_timeseries_legend_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_snapshot\_ttl module +---------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_ttl + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_snapshot\_type module +----------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_snapshot_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.create\_status\_page\_request module ------------------------------------------------------------------ diff --git a/examples/v2/reporting-and-sharing/CreateSnapshot.py b/examples/v2/reporting-and-sharing/CreateSnapshot.py new file mode 100644 index 0000000000..ab4652be2f --- /dev/null +++ b/examples/v2/reporting-and-sharing/CreateSnapshot.py @@ -0,0 +1,51 @@ +""" +Create a graph snapshot returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.reportingand_sharing_api import ReportingandSharingApi +from datadog_api_client.v2.model.create_snapshot_additional_config import CreateSnapshotAdditionalConfig +from datadog_api_client.v2.model.create_snapshot_data_attributes_request import CreateSnapshotDataAttributesRequest +from datadog_api_client.v2.model.create_snapshot_data_request import CreateSnapshotDataRequest +from datadog_api_client.v2.model.create_snapshot_request import CreateSnapshotRequest +from datadog_api_client.v2.model.create_snapshot_template_variable import CreateSnapshotTemplateVariable +from datadog_api_client.v2.model.create_snapshot_timeseries_legend_type import CreateSnapshotTimeseriesLegendType +from datadog_api_client.v2.model.create_snapshot_ttl import CreateSnapshotTTL +from datadog_api_client.v2.model.create_snapshot_type import CreateSnapshotType + +body = CreateSnapshotRequest( + data=CreateSnapshotDataRequest( + attributes=CreateSnapshotDataAttributesRequest( + additional_config=CreateSnapshotAdditionalConfig( + template_variables=[ + CreateSnapshotTemplateVariable( + name="host", + prefix="host", + values=[ + "web-server-1", + "web-server-2", + ], + ), + ], + timeseries_legend_type=CreateSnapshotTimeseriesLegendType.EXPANDED, + timezone_offset_minutes=300, + ), + end=1692464800000, + height=185, + is_authenticated=False, + start=1692464000000, + ttl=CreateSnapshotTTL.SIXTY_DAYS, + widget_definition=dict([("requests", "[{'q': 'avg:system.cpu.user{*}'}]"), ("type", "timeseries")]), + width=300, + ), + type=CreateSnapshotType.CREATE_SNAPSHOT, + ), +) + +configuration = Configuration() +configuration.unstable_operations["create_snapshot"] = True +with ApiClient(configuration) as api_client: + api_instance = ReportingandSharingApi(api_client) + response = api_instance.create_snapshot(body=body) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 8b4eca8cc0..09ccfd74c7 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -728,6 +728,7 @@ def __init__( "v2.get_slo_report": False, "v2.get_slo_report_job_status": False, "v2.get_slo_status": False, + "v2.create_snapshot": False, "v2.get_spa_recommendations": False, "v2.get_spa_recommendations_with_shard": False, "v2.create_ai_custom_rule": False, diff --git a/src/datadog_api_client/v2/api/reporting_and_sharing_api.py b/src/datadog_api_client/v2/api/reporting_and_sharing_api.py new file mode 100644 index 0000000000..818fa16f8b --- /dev/null +++ b/src/datadog_api_client/v2/api/reporting_and_sharing_api.py @@ -0,0 +1,58 @@ +# 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. +from __future__ import annotations + +from typing import Any, Dict + +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.configuration import Configuration +from datadog_api_client.v2.model.create_snapshot_response import CreateSnapshotResponse +from datadog_api_client.v2.model.create_snapshot_request import CreateSnapshotRequest + + +class ReportingandSharingApi: + """ + The Reporting and Sharing endpoints allow you to create snapshots of graph widgets and other shareable resources. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient(Configuration()) + self.api_client = api_client + + self._create_snapshot_endpoint = _Endpoint( + settings={ + "response_type": (CreateSnapshotResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/snapshot", + "operation_id": "create_snapshot", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (CreateSnapshotRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + def create_snapshot( + self, + body: CreateSnapshotRequest, + ) -> CreateSnapshotResponse: + """Create a graph snapshot. + + Create a snapshot of a graph widget. The snapshot is rendered asynchronously; the returned URL can be polled until the image is ready. + + :type body: CreateSnapshotRequest + :rtype: CreateSnapshotResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._create_snapshot_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index 1e147db9bf..b62e64a055 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -93,6 +93,7 @@ from datadog_api_client.v2.api.rum_remote_config_api import RUMRemoteConfigApi from datadog_api_client.v2.api.reference_tables_api import ReferenceTablesApi from datadog_api_client.v2.api.report_schedules_api import ReportSchedulesApi +from datadog_api_client.v2.api.reportingand_sharing_api import ReportingandSharingApi from datadog_api_client.v2.api.restriction_policies_api import RestrictionPoliciesApi from datadog_api_client.v2.api.roles_api import RolesApi from datadog_api_client.v2.api.rum_audience_management_api import RumAudienceManagementApi @@ -230,6 +231,7 @@ "RUMRemoteConfigApi", "ReferenceTablesApi", "ReportSchedulesApi", + "ReportingandSharingApi", "RestrictionPoliciesApi", "RolesApi", "RumAudienceManagementApi", diff --git a/src/datadog_api_client/v2/model/create_snapshot_additional_config.py b/src/datadog_api_client/v2/model/create_snapshot_additional_config.py new file mode 100644 index 0000000000..6b6959e6b5 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_additional_config.py @@ -0,0 +1,66 @@ +# 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. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.create_snapshot_template_variable import CreateSnapshotTemplateVariable + from datadog_api_client.v2.model.create_snapshot_timeseries_legend_type import CreateSnapshotTimeseriesLegendType + + +class CreateSnapshotAdditionalConfig(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_snapshot_template_variable import CreateSnapshotTemplateVariable + from datadog_api_client.v2.model.create_snapshot_timeseries_legend_type import ( + CreateSnapshotTimeseriesLegendType, + ) + + return { + "template_variables": ([CreateSnapshotTemplateVariable],), + "timeseries_legend_type": (CreateSnapshotTimeseriesLegendType,), + "timezone_offset_minutes": (int,), + } + + attribute_map = { + "template_variables": "template_variables", + "timeseries_legend_type": "timeseries_legend_type", + "timezone_offset_minutes": "timezone_offset_minutes", + } + + def __init__( + self_, + template_variables: Union[List[CreateSnapshotTemplateVariable], UnsetType] = unset, + timeseries_legend_type: Union[CreateSnapshotTimeseriesLegendType, UnsetType] = unset, + timezone_offset_minutes: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + Additional configuration options for snapshot creation. + + :param template_variables: List of template variable definitions for snapshot rendering. + :type template_variables: [CreateSnapshotTemplateVariable], optional + + :param timeseries_legend_type: The legend display type for timeseries widgets. A value of ``none`` hides the legend entirely; omitting the field lets the frontend choose automatically. + :type timeseries_legend_type: CreateSnapshotTimeseriesLegendType, optional + + :param timezone_offset_minutes: Timezone offset in minutes from UTC. Positive values are west of UTC (for example, ``300`` for UTC-5). Use ``0`` for UTC. + :type timezone_offset_minutes: int, optional + """ + if template_variables is not unset: + kwargs["template_variables"] = template_variables + if timeseries_legend_type is not unset: + kwargs["timeseries_legend_type"] = timeseries_legend_type + if timezone_offset_minutes is not unset: + kwargs["timezone_offset_minutes"] = timezone_offset_minutes + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/create_snapshot_data_attributes_request.py b/src/datadog_api_client/v2/model/create_snapshot_data_attributes_request.py new file mode 100644 index 0000000000..20a7a2475d --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_data_attributes_request.py @@ -0,0 +1,121 @@ +# 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. +from __future__ import annotations + +from typing import Any, Dict, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + date, + datetime, + none_type, + unset, + UnsetType, + UUID, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.create_snapshot_additional_config import CreateSnapshotAdditionalConfig + from datadog_api_client.v2.model.create_snapshot_ttl import CreateSnapshotTTL + + +class CreateSnapshotDataAttributesRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_snapshot_additional_config import CreateSnapshotAdditionalConfig + from datadog_api_client.v2.model.create_snapshot_ttl import CreateSnapshotTTL + + return { + "additional_config": (CreateSnapshotAdditionalConfig,), + "end": (int,), + "height": (int,), + "is_authenticated": (bool,), + "start": (int,), + "ttl": (CreateSnapshotTTL,), + "widget_definition": ( + { + str: ( + bool, + date, + datetime, + dict, + float, + int, + list, + str, + UUID, + none_type, + ) + }, + ), + "width": (int,), + } + + attribute_map = { + "additional_config": "additional_config", + "end": "end", + "height": "height", + "is_authenticated": "is_authenticated", + "start": "start", + "ttl": "ttl", + "widget_definition": "widget_definition", + "width": "width", + } + + def __init__( + self_, + end: int, + start: int, + widget_definition: Dict[str, Any], + additional_config: Union[CreateSnapshotAdditionalConfig, UnsetType] = unset, + height: Union[int, UnsetType] = unset, + is_authenticated: Union[bool, UnsetType] = unset, + ttl: Union[CreateSnapshotTTL, UnsetType] = unset, + width: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + Attributes for snapshot creation. + + :param additional_config: Additional configuration options for snapshot creation. + :type additional_config: CreateSnapshotAdditionalConfig, optional + + :param end: End of the time window for the snapshot, in milliseconds since Unix epoch. + :type end: int + + :param height: The height of the rendered snapshot in pixels. + :type height: int, optional + + :param is_authenticated: Whether the snapshot requires authentication to view. Authenticated snapshots are scoped to the creating organization. + :type is_authenticated: bool, optional + + :param start: Start of the time window for the snapshot, in milliseconds since Unix epoch. + :type start: int + + :param ttl: The time-to-live for the snapshot. This value corresponds to storage lifecycle policies that automatically delete the snapshot after the specified period. + :type ttl: CreateSnapshotTTL, optional + + :param widget_definition: The widget definition to render as a snapshot. Must include a valid ``type`` field and non-empty ``requests`` array. + :type widget_definition: {str: (bool, date, datetime, dict, float, int, list, str, UUID, none_type,)} + + :param width: The width of the rendered snapshot in pixels. + :type width: int, optional + """ + if additional_config is not unset: + kwargs["additional_config"] = additional_config + if height is not unset: + kwargs["height"] = height + if is_authenticated is not unset: + kwargs["is_authenticated"] = is_authenticated + if ttl is not unset: + kwargs["ttl"] = ttl + if width is not unset: + kwargs["width"] = width + super().__init__(kwargs) + + self_.end = end + self_.start = start + self_.widget_definition = widget_definition diff --git a/src/datadog_api_client/v2/model/create_snapshot_data_attributes_response.py b/src/datadog_api_client/v2/model/create_snapshot_data_attributes_response.py new file mode 100644 index 0000000000..6ca72dfb72 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_data_attributes_response.py @@ -0,0 +1,33 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class CreateSnapshotDataAttributesResponse(ModelNormal): + @cached_property + def openapi_types(_): + return { + "url": (str,), + } + + attribute_map = { + "url": "url", + } + + def __init__(self_, url: str, **kwargs): + """ + Attributes of the created snapshot. + + :param url: The URL to access the rendered snapshot image. + :type url: str + """ + super().__init__(kwargs) + + self_.url = url diff --git a/src/datadog_api_client/v2/model/create_snapshot_data_request.py b/src/datadog_api_client/v2/model/create_snapshot_data_request.py new file mode 100644 index 0000000000..2133f77ba9 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_data_request.py @@ -0,0 +1,50 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.create_snapshot_data_attributes_request import CreateSnapshotDataAttributesRequest + from datadog_api_client.v2.model.create_snapshot_type import CreateSnapshotType + + +class CreateSnapshotDataRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_snapshot_data_attributes_request import ( + CreateSnapshotDataAttributesRequest, + ) + from datadog_api_client.v2.model.create_snapshot_type import CreateSnapshotType + + return { + "attributes": (CreateSnapshotDataAttributesRequest,), + "type": (CreateSnapshotType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__(self_, attributes: CreateSnapshotDataAttributesRequest, type: CreateSnapshotType, **kwargs): + """ + Data envelope for snapshot creation. + + :param attributes: Attributes for snapshot creation. + :type attributes: CreateSnapshotDataAttributesRequest + + :param type: The type identifier for snapshot creation resources. + :type type: CreateSnapshotType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/create_snapshot_data_response.py b/src/datadog_api_client/v2/model/create_snapshot_data_response.py new file mode 100644 index 0000000000..6100127c6e --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_data_response.py @@ -0,0 +1,58 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.create_snapshot_data_attributes_response import ( + CreateSnapshotDataAttributesResponse, + ) + from datadog_api_client.v2.model.create_snapshot_type import CreateSnapshotType + + +class CreateSnapshotDataResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_snapshot_data_attributes_response import ( + CreateSnapshotDataAttributesResponse, + ) + from datadog_api_client.v2.model.create_snapshot_type import CreateSnapshotType + + return { + "attributes": (CreateSnapshotDataAttributesResponse,), + "id": (str,), + "type": (CreateSnapshotType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: CreateSnapshotDataAttributesResponse, id: str, type: CreateSnapshotType, **kwargs): + """ + Data envelope for the snapshot creation response. + + :param attributes: Attributes of the created snapshot. + :type attributes: CreateSnapshotDataAttributesResponse + + :param id: The unique identifier of the created snapshot. + :type id: str + + :param type: The type identifier for snapshot creation resources. + :type type: CreateSnapshotType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/create_snapshot_request.py b/src/datadog_api_client/v2/model/create_snapshot_request.py new file mode 100644 index 0000000000..8b0afc33e0 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_request.py @@ -0,0 +1,40 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.create_snapshot_data_request import CreateSnapshotDataRequest + + +class CreateSnapshotRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_snapshot_data_request import CreateSnapshotDataRequest + + return { + "data": (CreateSnapshotDataRequest,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: CreateSnapshotDataRequest, **kwargs): + """ + Request body for creating a graph snapshot. + + :param data: Data envelope for snapshot creation. + :type data: CreateSnapshotDataRequest + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/create_snapshot_response.py b/src/datadog_api_client/v2/model/create_snapshot_response.py new file mode 100644 index 0000000000..af7f03e233 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_response.py @@ -0,0 +1,40 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.create_snapshot_data_response import CreateSnapshotDataResponse + + +class CreateSnapshotResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_snapshot_data_response import CreateSnapshotDataResponse + + return { + "data": (CreateSnapshotDataResponse,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: CreateSnapshotDataResponse, **kwargs): + """ + Response body for a snapshot creation request. + + :param data: Data envelope for the snapshot creation response. + :type data: CreateSnapshotDataResponse + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/create_snapshot_template_variable.py b/src/datadog_api_client/v2/model/create_snapshot_template_variable.py new file mode 100644 index 0000000000..b8b4cb1e87 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_template_variable.py @@ -0,0 +1,46 @@ +# 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. +from __future__ import annotations + +from typing import List + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class CreateSnapshotTemplateVariable(ModelNormal): + @cached_property + def openapi_types(_): + return { + "name": (str,), + "prefix": (str,), + "values": ([str],), + } + + attribute_map = { + "name": "name", + "prefix": "prefix", + "values": "values", + } + + def __init__(self_, name: str, prefix: str, values: List[str], **kwargs): + """ + A template variable definition for snapshot rendering. + + :param name: The template variable name. + :type name: str + + :param prefix: The tag prefix associated with the template variable. For example, a prefix of ``host`` with a value of ``web-server-1`` scopes the snapshot to ``host:web-server-1``. + :type prefix: str + + :param values: The list of scoped values for this template variable. + :type values: [str] + """ + super().__init__(kwargs) + + self_.name = name + self_.prefix = prefix + self_.values = values diff --git a/src/datadog_api_client/v2/model/create_snapshot_timeseries_legend_type.py b/src/datadog_api_client/v2/model/create_snapshot_timeseries_legend_type.py new file mode 100644 index 0000000000..486d8f576d --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_timeseries_legend_type.py @@ -0,0 +1,41 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class CreateSnapshotTimeseriesLegendType(ModelSimple): + """ + The legend display type for timeseries widgets. A value of `none` hides the legend entirely; omitting the field lets the frontend choose automatically. + + :param value: Must be one of ["compact", "expanded", "none"]. + :type value: str + """ + + allowed_values = { + "compact", + "expanded", + "none", + } + COMPACT: ClassVar["CreateSnapshotTimeseriesLegendType"] + EXPANDED: ClassVar["CreateSnapshotTimeseriesLegendType"] + NONE: ClassVar["CreateSnapshotTimeseriesLegendType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +CreateSnapshotTimeseriesLegendType.COMPACT = CreateSnapshotTimeseriesLegendType("compact") +CreateSnapshotTimeseriesLegendType.EXPANDED = CreateSnapshotTimeseriesLegendType("expanded") +CreateSnapshotTimeseriesLegendType.NONE = CreateSnapshotTimeseriesLegendType("none") diff --git a/src/datadog_api_client/v2/model/create_snapshot_ttl.py b/src/datadog_api_client/v2/model/create_snapshot_ttl.py new file mode 100644 index 0000000000..cd8cc745e8 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_ttl.py @@ -0,0 +1,50 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class CreateSnapshotTTL(ModelSimple): + """ + The time-to-live for the snapshot. This value corresponds to storage lifecycle policies that automatically delete the snapshot after the specified period. + + :param value: Must be one of ["30d", "60d", "90d", "1y", "2y", "inf"]. + :type value: str + """ + + allowed_values = { + "30d", + "60d", + "90d", + "1y", + "2y", + "inf", + } + THIRTY_DAYS: ClassVar["CreateSnapshotTTL"] + SIXTY_DAYS: ClassVar["CreateSnapshotTTL"] + NINETY_DAYS: ClassVar["CreateSnapshotTTL"] + ONE_YEAR: ClassVar["CreateSnapshotTTL"] + TWO_YEARS: ClassVar["CreateSnapshotTTL"] + INFINITE: ClassVar["CreateSnapshotTTL"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +CreateSnapshotTTL.THIRTY_DAYS = CreateSnapshotTTL("30d") +CreateSnapshotTTL.SIXTY_DAYS = CreateSnapshotTTL("60d") +CreateSnapshotTTL.NINETY_DAYS = CreateSnapshotTTL("90d") +CreateSnapshotTTL.ONE_YEAR = CreateSnapshotTTL("1y") +CreateSnapshotTTL.TWO_YEARS = CreateSnapshotTTL("2y") +CreateSnapshotTTL.INFINITE = CreateSnapshotTTL("inf") diff --git a/src/datadog_api_client/v2/model/create_snapshot_type.py b/src/datadog_api_client/v2/model/create_snapshot_type.py new file mode 100644 index 0000000000..b845e6a406 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_snapshot_type.py @@ -0,0 +1,35 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class CreateSnapshotType(ModelSimple): + """ + The type identifier for snapshot creation resources. + + :param value: If omitted defaults to "create_snapshot". Must be one of ["create_snapshot"]. + :type value: str + """ + + allowed_values = { + "create_snapshot", + } + CREATE_SNAPSHOT: ClassVar["CreateSnapshotType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +CreateSnapshotType.CREATE_SNAPSHOT = CreateSnapshotType("create_snapshot") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 998d656dbd..32ace949ed 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -1758,6 +1758,17 @@ from datadog_api_client.v2.model.create_service_now_ticket_request_data_relationships import ( CreateServiceNowTicketRequestDataRelationships, ) +from datadog_api_client.v2.model.create_snapshot_additional_config import CreateSnapshotAdditionalConfig +from datadog_api_client.v2.model.create_snapshot_data_attributes_request import CreateSnapshotDataAttributesRequest +from datadog_api_client.v2.model.create_snapshot_data_attributes_response import CreateSnapshotDataAttributesResponse +from datadog_api_client.v2.model.create_snapshot_data_request import CreateSnapshotDataRequest +from datadog_api_client.v2.model.create_snapshot_data_response import CreateSnapshotDataResponse +from datadog_api_client.v2.model.create_snapshot_request import CreateSnapshotRequest +from datadog_api_client.v2.model.create_snapshot_response import CreateSnapshotResponse +from datadog_api_client.v2.model.create_snapshot_ttl import CreateSnapshotTTL +from datadog_api_client.v2.model.create_snapshot_template_variable import CreateSnapshotTemplateVariable +from datadog_api_client.v2.model.create_snapshot_timeseries_legend_type import CreateSnapshotTimeseriesLegendType +from datadog_api_client.v2.model.create_snapshot_type import CreateSnapshotType from datadog_api_client.v2.model.create_status_page_request import CreateStatusPageRequest from datadog_api_client.v2.model.create_status_page_request_data import CreateStatusPageRequestData from datadog_api_client.v2.model.create_status_page_request_data_attributes import CreateStatusPageRequestDataAttributes @@ -10887,6 +10898,17 @@ "CreateServiceNowTicketRequestData", "CreateServiceNowTicketRequestDataAttributes", "CreateServiceNowTicketRequestDataRelationships", + "CreateSnapshotAdditionalConfig", + "CreateSnapshotDataAttributesRequest", + "CreateSnapshotDataAttributesResponse", + "CreateSnapshotDataRequest", + "CreateSnapshotDataResponse", + "CreateSnapshotRequest", + "CreateSnapshotResponse", + "CreateSnapshotTTL", + "CreateSnapshotTemplateVariable", + "CreateSnapshotTimeseriesLegendType", + "CreateSnapshotType", "CreateStatusPageRequest", "CreateStatusPageRequestData", "CreateStatusPageRequestDataAttributes", diff --git a/tests/v2/features/reporting_and_sharing.feature b/tests/v2/features/reporting_and_sharing.feature new file mode 100644 index 0000000000..f852b68d44 --- /dev/null +++ b/tests/v2/features/reporting_and_sharing.feature @@ -0,0 +1,27 @@ +@endpoint(reporting-and-sharing) @endpoint(reporting-and-sharing-v2) +Feature: Reporting and Sharing + The Reporting and Sharing endpoints allow you to create snapshots of graph + widgets and other shareable resources. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "ReportingandSharing" API + And operation "CreateSnapshot" enabled + And new "CreateSnapshot" request + And body with value {"data": {"attributes": {"additional_config": {"template_variables": [{"name": "host", "prefix": "host", "values": ["web-server-1", "web-server-2"]}], "timeseries_legend_type": "expanded", "timezone_offset_minutes": 300}, "end": 1692464800000, "height": 185, "is_authenticated": false, "start": 1692464000000, "ttl": "60d", "widget_definition": {"requests": [{"q": "avg:system.cpu.user{*}"}], "type": "timeseries"}, "width": 300}, "type": "create_snapshot"}} + + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: Create a graph snapshot returns "Bad Request" response + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: Create a graph snapshot returns "Not Found" response + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: Create a graph snapshot returns "OK" response + When the request is sent + Then the response status is 200 OK diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 486933f758..c589f22d8b 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -8184,6 +8184,12 @@ "type": "safe" } }, + "CreateSnapshot": { + "tag": "Reporting and Sharing", + "undo": { + "type": "unsafe" + } + }, "GetSPARecommendations": { "tag": "Spa", "undo": {