diff --git a/.apigentools-info b/.apigentools-info index 88c58be4cbf2..33098573d3cf 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-02-04 14:10:05.819748", - "spec_repo_commit": "4fb9047a" + "regenerated": "2025-02-05 20:58:57.604084", + "spec_repo_commit": "82f3d557" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-02-04 14:10:05.835266", - "spec_repo_commit": "4fb9047a" + "regenerated": "2025-02-05 20:58:57.624279", + "spec_repo_commit": "82f3d557" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 831530e2584b..5ed10deb3209 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1965,6 +1965,24 @@ components: deployment: $ref: '#/components/schemas/DeploymentRelationship' type: object + AppVersionSelector: + description: The version selector parameter used in endpoints such as Get App. + Version numbers start at 1 and increment with each update. 0 is a special + value that always selects the latest version. + oneOf: + - $ref: '#/components/schemas/AppVersionSelectorConstants' + - format: int64 + minimum: 0 + type: integer + AppVersionSelectorConstants: + description: Constants that always select a particular version of an app. + enum: + - latest + - deployed + type: string + x-enum-varnames: + - LATEST + - DEPLOYED ApplicationKeyCreateAttributes: description: Attributes used to create an application Key. properties: @@ -32494,7 +32512,7 @@ paths: name: version required: false schema: - type: string + $ref: '#/components/schemas/AppVersionSelector' responses: '200': content: @@ -32520,6 +32538,12 @@ paths: schema: $ref: '#/components/schemas/JSONAPIErrorResponse' description: Not Found + '410': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Gone '429': $ref: '#/components/responses/TooManyRequestsResponse' summary: Get App diff --git a/cassettes/features/v2/app_builder/Get-App-returns-Gone-response.frozen b/cassettes/features/v2/app_builder/Get-App-returns-Gone-response.frozen new file mode 100644 index 000000000000..2d54f285b660 --- /dev/null +++ b/cassettes/features/v2/app_builder/Get-App-returns-Gone-response.frozen @@ -0,0 +1 @@ +2025-02-05T20:55:28.999Z \ No newline at end of file diff --git a/cassettes/features/v2/app_builder/Get-App-returns-Gone-response.yml b/cassettes/features/v2/app_builder/Get-App-returns-Gone-response.yml new file mode 100644 index 000000000000..8577064c2509 --- /dev/null +++ b/cassettes/features/v2/app_builder/Get-App-returns-Gone-response.yml @@ -0,0 +1,62 @@ +http_interactions: +- recorded_at: Wed, 05 Feb 2025 20:55:28 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"components":[{"events":[],"name":"grid0","properties":{"children":[{"events":[],"name":"gridCell0","properties":{"children":[{"events":[],"name":"calloutValue0","properties":{"isDisabled":false,"isLoading":false,"isVisible":true,"label":"CPU + Usage","size":"sm","style":"vivid_yellow","unit":"kB","value":"42"},"type":"calloutValue"}],"isVisible":"true","layout":{"default":{"height":8,"width":2,"x":0,"y":0}}},"type":"gridCell"}]},"type":"grid"}],"description":"This + is a simple example app","name":"Example App","queries":[],"rootInstanceName":"grid0"},"type":"appDefinitions"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/app-builder/apps + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"e72edfaf-cb14-4a35-acf6-da5f7d8f9ab3","type":"appDefinitions"}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Wed, 05 Feb 2025 20:55:28 GMT + request: + body: null + headers: + Accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/app-builder/apps/e72edfaf-cb14-4a35-acf6-da5f7d8f9ab3?version=31 + response: + body: + encoding: UTF-8 + string: '{"errors":[{"title":"app version not found"}]}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 410 + message: Gone +- recorded_at: Wed, 05 Feb 2025 20:55:28 GMT + request: + body: null + headers: + Accept: + - application/json + method: DELETE + uri: https://api.datadoghq.com/api/v2/app-builder/apps/e72edfaf-cb14-4a35-acf6-da5f7d8f9ab3 + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"e72edfaf-cb14-4a35-acf6-da5f7d8f9ab3","type":"appDefinitions"}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 4a514e4b32a7..1554069446ad 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -980,7 +980,7 @@ }, "v2.GetApp" => { "app_id" => "UUID", - "version" => "String", + "version" => "AppVersionSelector", }, "v2.UpdateApp" => { "app_id" => "UUID", diff --git a/features/v2/app_builder.feature b/features/v2/app_builder.feature index 1c8226e89709..a5e735e1314f 100644 --- a/features/v2/app_builder.feature +++ b/features/v2/app_builder.feature @@ -99,6 +99,16 @@ Feature: App Builder When the request is sent Then the response status is 400 Bad Request + @skip-typescript @team:DataDog/app-builder-backend + Scenario: Get App returns "Gone" response + Given operation "GetApp" enabled + And new "GetApp" request + And there is a valid "app" in the system + And request contains "app_id" parameter from "app.data.id" + And request contains "version" parameter with value 31 + When the request is sent + Then the response status is 410 Gone + @skip-typescript @team:DataDog/app-builder-backend Scenario: Get App returns "Not Found" response Given operation "GetApp" enabled diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index d77c46229ab8..4fcab4beadd5 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -958,6 +958,8 @@ def overrides "v2.app_meta" => "AppMeta", "v2.app_relationship" => "AppRelationship", "v2.apps_sort_field" => "AppsSortField", + "v2.app_version_selector" => "AppVersionSelector", + "v2.app_version_selector_constants" => "AppVersionSelectorConstants", "v2.asset" => "Asset", "v2.asset_attributes" => "AssetAttributes", "v2.asset_entity_type" => "AssetEntityType", diff --git a/lib/datadog_api_client/v2/api/app_builder_api.rb b/lib/datadog_api_client/v2/api/app_builder_api.rb index b9bf48c8adb3..bcfa74919a7b 100644 --- a/lib/datadog_api_client/v2/api/app_builder_api.rb +++ b/lib/datadog_api_client/v2/api/app_builder_api.rb @@ -254,7 +254,7 @@ def get_app(app_id, opts = {}) # # @param app_id [UUID] The ID of the app to retrieve. # @param opts [Hash] the optional parameters - # @option opts [String] :version The version number of the app to retrieve. If not specified, the latest version is returned. Version numbers start at 1 and increment with each update. The special values `latest` and `deployed` can be used to retrieve the latest version or the published version, respectively. + # @option opts [AppVersionSelector] :version The version number of the app to retrieve. If not specified, the latest version is returned. Version numbers start at 1 and increment with each update. The special values `latest` and `deployed` can be used to retrieve the latest version or the published version, respectively. # @return [Array<(GetAppResponse, Integer, Hash)>] GetAppResponse data, response status code and response headers def get_app_with_http_info(app_id, opts = {}) unstable_enabled = @api_client.config.unstable_operations["v2.get_app".to_sym] diff --git a/lib/datadog_api_client/v2/models/app_version_selector.rb b/lib/datadog_api_client/v2/models/app_version_selector.rb new file mode 100644 index 000000000000..46622e639b06 --- /dev/null +++ b/lib/datadog_api_client/v2/models/app_version_selector.rb @@ -0,0 +1,63 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The version selector parameter used in endpoints such as Get App. Version numbers start at 1 and increment with each update. 0 is a special value that always selects the latest version. + module AppVersionSelector + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'AppVersionSelectorConstants', + :'Integer' + ] + end + # Builds the object + # @param data [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end diff --git a/lib/datadog_api_client/v2/models/app_version_selector_constants.rb b/lib/datadog_api_client/v2/models/app_version_selector_constants.rb new file mode 100644 index 000000000000..3300e7a9f343 --- /dev/null +++ b/lib/datadog_api_client/v2/models/app_version_selector_constants.rb @@ -0,0 +1,27 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Constants that always select a particular version of an app. + class AppVersionSelectorConstants + include BaseEnumModel + + LATEST = "latest".freeze + DEPLOYED = "deployed".freeze + end +end