diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 39f6901f1a8c..c7a12f626409 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -61289,6 +61289,136 @@ components: - name - options type: object + UpdateFlakyTestsRequest: + description: Request to update the state of multiple flaky tests. + properties: + data: + $ref: '#/components/schemas/UpdateFlakyTestsRequestData' + required: + - data + type: object + UpdateFlakyTestsRequestAttributes: + description: Attributes for updating flaky test states. + properties: + tests: + description: List of flaky tests to update. + items: + $ref: '#/components/schemas/UpdateFlakyTestsRequestTest' + type: array + required: + - tests + type: object + UpdateFlakyTestsRequestData: + description: The JSON:API data for updating flaky test states. + properties: + attributes: + $ref: '#/components/schemas/UpdateFlakyTestsRequestAttributes' + type: + $ref: '#/components/schemas/UpdateFlakyTestsRequestDataType' + required: + - type + - attributes + type: object + UpdateFlakyTestsRequestDataType: + description: The definition of `UpdateFlakyTestsRequestDataType` object. + enum: + - update_flaky_test_state_request + example: update_flaky_test_state_request + type: string + x-enum-varnames: + - UPDATE_FLAKY_TEST_STATE_REQUEST + UpdateFlakyTestsRequestTest: + description: Details of what tests to update and their new attributes. + properties: + id: + description: The ID of the flaky test. This is the same ID returned by the + Search flaky tests endpoint and corresponds to the test_fingerprint_fqn + field in test run events. + example: 4eb1887a8adb1847 + type: string + new_state: + $ref: '#/components/schemas/UpdateFlakyTestsRequestTestNewState' + required: + - id + - new_state + type: object + UpdateFlakyTestsRequestTestNewState: + description: The new state to set for the flaky test. + enum: + - active + - quarantined + - disabled + - fixed + example: active + type: string + x-enum-varnames: + - ACTIVE + - QUARANTINED + - DISABLED + - FIXED + UpdateFlakyTestsResponse: + description: Response object for updating flaky test states. + properties: + data: + $ref: '#/components/schemas/UpdateFlakyTestsResponseData' + type: object + UpdateFlakyTestsResponseAttributes: + description: Attributes for the update flaky test state response. + properties: + has_errors: + description: '`True` if any errors occurred during the update operations. + `False` if all tests succeeded to be updated.' + example: true + type: boolean + results: + description: Results of the update operation for each test. + items: + $ref: '#/components/schemas/UpdateFlakyTestsResponseResult' + type: array + required: + - has_errors + - results + type: object + UpdateFlakyTestsResponseData: + description: Summary of the update operations. Tells whether a test succeeded + or failed to be updated. + properties: + attributes: + $ref: '#/components/schemas/UpdateFlakyTestsResponseAttributes' + id: + description: The ID of the response. + type: string + type: + $ref: '#/components/schemas/UpdateFlakyTestsResponseDataType' + type: object + UpdateFlakyTestsResponseDataType: + description: The definition of `UpdateFlakyTestsResponseDataType` object. + enum: + - update_flaky_test_state_response + type: string + x-enum-varnames: + - UPDATE_FLAKY_TEST_STATE_RESPONSE + UpdateFlakyTestsResponseResult: + description: Result of updating a single flaky test state. + properties: + error: + description: Error message if the update failed. + type: string + id: + description: The ID of the flaky test from the request. This is the same + ID returned by the Search flaky tests endpoint and corresponds to the + test_fingerprint_fqn field in test run events. + example: 4eb1887a8adb1847 + type: string + success: + description: '`True` if the update was successful, `False` if there were + any errors.' + example: false + type: boolean + required: + - id + - success + type: object UpdateOnCallNotificationRuleRequest: description: A top-level wrapper for updating a notification rule for a user example: @@ -63638,6 +63768,8 @@ components: teams_read: Read Teams data. A User with this permission can view Team names, metadata, and which Users are on each Team. test_optimization_read: View Test Optimization. + test_optimization_write: Update flaky tests from Flaky Tests Management + of Test Optimization. timeseries_query: Query Timeseries data. usage_read: View your organization's usage and usage attribution. user_access_invite: Invite other users to your organization. @@ -94850,6 +94982,44 @@ paths: - incident_settings_write x-unstable: '**Note**: This endpoint is deprecated. See the [Teams API endpoints](https://docs.datadoghq.com/api/latest/teams/).' /api/v2/test/flaky-test-management/tests: + patch: + description: Update the state of multiple flaky tests in Flaky Test Management. + operationId: UpdateFlakyTests + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateFlakyTestsRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateFlakyTestsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - test_optimization_write + summary: Update flaky test states + tags: + - Test Optimization + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - test_optimization_write + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' post: description: List endpoint returning flaky tests from Flaky Test Management. Results are paginated. diff --git a/examples/v2/test-optimization/UpdateFlakyTests.rb b/examples/v2/test-optimization/UpdateFlakyTests.rb new file mode 100644 index 000000000000..376f02413b7e --- /dev/null +++ b/examples/v2/test-optimization/UpdateFlakyTests.rb @@ -0,0 +1,22 @@ +# Update flaky test states returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.update_flaky_tests".to_sym] = true +end +api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new + +body = DatadogAPIClient::V2::UpdateFlakyTestsRequest.new({ + data: DatadogAPIClient::V2::UpdateFlakyTestsRequestData.new({ + attributes: DatadogAPIClient::V2::UpdateFlakyTestsRequestAttributes.new({ + tests: [ + DatadogAPIClient::V2::UpdateFlakyTestsRequestTest.new({ + id: "4eb1887a8adb1847", + new_state: DatadogAPIClient::V2::UpdateFlakyTestsRequestTestNewState::ACTIVE, + }), + ], + }), + type: DatadogAPIClient::V2::UpdateFlakyTestsRequestDataType::UPDATE_FLAKY_TEST_STATE_REQUEST, + }), +}) +p api_instance.update_flaky_tests(body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 6baf44d68412..9b8099259938 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3568,6 +3568,9 @@ "team_id" => "String", "body" => "IncidentTeamUpdateRequest", }, + "v2.UpdateFlakyTests" => { + "body" => "UpdateFlakyTestsRequest", + }, "v2.SearchFlakyTests" => { "body" => "FlakyTestsSearchRequest", }, diff --git a/features/v2/test_optimization.feature b/features/v2/test_optimization.feature index 18af1e9cad90..d21278d7646e 100644 --- a/features/v2/test_optimization.feature +++ b/features/v2/test_optimization.feature @@ -8,35 +8,59 @@ Feature: Test Optimization Given a valid "apiKeyAuth" key in the system And a valid "appKeyAuth" key in the system And an instance of "TestOptimization" API - And operation "SearchFlakyTests" enabled - And new "SearchFlakyTests" request @generated @skip @team:DataDog/ci-app-backend Scenario: Search flaky tests returns "Bad Request" response - Given body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} + Given operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} When the request is sent Then the response status is 400 Bad Request @skip @team:DataDog/ci-app-backend Scenario: Search flaky tests returns "Bad Request" response with invalid limit - Given body with value {"data": {"attributes": {"filter": {"query": "*"}, "page": {"limit": 2000}, "sort": "fqn"}, "type": "search_flaky_tests_request"}} + Given operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + And body with value {"data": {"attributes": {"filter": {"query": "*"}, "page": {"limit": 2000}, "sort": "fqn"}, "type": "search_flaky_tests_request"}} When the request is sent Then the response status is 400 Bad Request @generated @skip @team:DataDog/ci-app-backend Scenario: Search flaky tests returns "OK" response - Given body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} + Given operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} When the request is sent Then the response status is 200 OK @replay-only @skip @skip-validation @team:DataDog/ci-app-backend @with-pagination Scenario: Search flaky tests returns "OK" response with filtered query - Given body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/cart-tracking\""}, "page": {"limit": 10}, "sort": "-last_flaked"}, "type": "search_flaky_tests_request"}} + Given operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/cart-tracking\""}, "page": {"limit": 10}, "sort": "-last_flaked"}, "type": "search_flaky_tests_request"}} When the request with pagination is sent Then the response status is 200 OK @generated @skip @team:DataDog/ci-app-backend @with-pagination Scenario: Search flaky tests returns "OK" response with pagination - Given body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} + Given operation "SearchFlakyTests" enabled + And new "SearchFlakyTests" request + And body with value {"data": {"attributes": {"filter": {"query": "flaky_test_state:active @git.repository.id_v2:\"github.com/datadog/shopist\""}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "failure_rate"}, "type": "search_flaky_tests_request"}} When the request with pagination is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update flaky test states returns "Bad Request" response + Given operation "UpdateFlakyTests" enabled + And new "UpdateFlakyTests" request + And body with value {"data": {"attributes": {"tests": [{"id": "4eb1887a8adb1847", "new_state": "active"}]}, "type": "update_flaky_test_state_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update flaky test states returns "OK" response + Given operation "UpdateFlakyTests" enabled + And new "UpdateFlakyTests" request + And body with value {"data": {"attributes": {"tests": [{"id": "4eb1887a8adb1847", "new_state": "active"}]}, "type": "update_flaky_test_state_request"}} + When the request is sent + Then the response status is 200 OK diff --git a/features/v2/undo.json b/features/v2/undo.json index bfcee722b4e8..980e3bbbace6 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -5149,6 +5149,12 @@ "type": "idempotent" } }, + "UpdateFlakyTests": { + "tag": "Test Optimization", + "undo": { + "type": "unsafe" + } + }, "SearchFlakyTests": { "tag": "Test Optimization", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index d94287927f32..b496df9696d1 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -357,6 +357,7 @@ def initialize "v2.list_incident_teams": false, "v2.update_incident_team": false, "v2.search_flaky_tests": false, + "v2.update_flaky_tests": false, } @server_variables[:site] = ENV['DD_SITE'] if ENV.key? 'DD_SITE' @api_key['apiKeyAuth'] = ENV['DD_API_KEY'] if ENV.key? 'DD_API_KEY' diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 7c462f3abf52..ca645cd3c611 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -4809,6 +4809,17 @@ def overrides "v2.update_deployment_rule_params" => "UpdateDeploymentRuleParams", "v2.update_deployment_rule_params_data" => "UpdateDeploymentRuleParamsData", "v2.update_deployment_rule_params_data_attributes" => "UpdateDeploymentRuleParamsDataAttributes", + "v2.update_flaky_tests_request" => "UpdateFlakyTestsRequest", + "v2.update_flaky_tests_request_attributes" => "UpdateFlakyTestsRequestAttributes", + "v2.update_flaky_tests_request_data" => "UpdateFlakyTestsRequestData", + "v2.update_flaky_tests_request_data_type" => "UpdateFlakyTestsRequestDataType", + "v2.update_flaky_tests_request_test" => "UpdateFlakyTestsRequestTest", + "v2.update_flaky_tests_request_test_new_state" => "UpdateFlakyTestsRequestTestNewState", + "v2.update_flaky_tests_response" => "UpdateFlakyTestsResponse", + "v2.update_flaky_tests_response_attributes" => "UpdateFlakyTestsResponseAttributes", + "v2.update_flaky_tests_response_data" => "UpdateFlakyTestsResponseData", + "v2.update_flaky_tests_response_data_type" => "UpdateFlakyTestsResponseDataType", + "v2.update_flaky_tests_response_result" => "UpdateFlakyTestsResponseResult", "v2.update_on_call_notification_rule_request" => "UpdateOnCallNotificationRuleRequest", "v2.update_on_call_notification_rule_request_attributes" => "UpdateOnCallNotificationRuleRequestAttributes", "v2.update_on_call_notification_rule_request_data" => "UpdateOnCallNotificationRuleRequestData", diff --git a/lib/datadog_api_client/v2/api/test_optimization_api.rb b/lib/datadog_api_client/v2/api/test_optimization_api.rb index 6d41419f5594..9a9967c7dfa1 100644 --- a/lib/datadog_api_client/v2/api/test_optimization_api.rb +++ b/lib/datadog_api_client/v2/api/test_optimization_api.rb @@ -112,5 +112,78 @@ def search_flaky_tests_with_pagination(opts = {}) @api_client.set_attribute_from_path(api_version, opts, "body.data.attributes.page.cursor", FlakyTestsSearchRequest, @api_client.get_attribute_from_path(response, "meta.pagination.next_page")) end end + + # Update flaky test states. + # + # @see #update_flaky_tests_with_http_info + def update_flaky_tests(body, opts = {}) + data, _status_code, _headers = update_flaky_tests_with_http_info(body, opts) + data + end + + # Update flaky test states. + # + # Update the state of multiple flaky tests in Flaky Test Management. + # + # @param body [UpdateFlakyTestsRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(UpdateFlakyTestsResponse, Integer, Hash)>] UpdateFlakyTestsResponse data, response status code and response headers + def update_flaky_tests_with_http_info(body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.update_flaky_tests".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.update_flaky_tests") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.update_flaky_tests")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TestOptimizationAPI.update_flaky_tests ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling TestOptimizationAPI.update_flaky_tests" + end + # resource path + local_var_path = '/api/v2/test/flaky-test-management/tests' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'UpdateFlakyTestsResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :update_flaky_tests, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Patch, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TestOptimizationAPI#update_flaky_tests\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_request.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_request.rb new file mode 100644 index 000000000000..bac2861f2b62 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_request.rb @@ -0,0 +1,123 @@ +=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 + # Request to update the state of multiple flaky tests. + class UpdateFlakyTestsRequest + include BaseGenericModel + + # The JSON:API data for updating flaky test states. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'UpdateFlakyTestsRequestData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateFlakyTestsRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_request_attributes.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_request_attributes.rb new file mode 100644 index 000000000000..f9718f150228 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_request_attributes.rb @@ -0,0 +1,125 @@ +=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 + # Attributes for updating flaky test states. + class UpdateFlakyTestsRequestAttributes + include BaseGenericModel + + # List of flaky tests to update. + attr_reader :tests + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'tests' => :'tests' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'tests' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateFlakyTestsRequestAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'tests') + if (value = attributes[:'tests']).is_a?(Array) + self.tests = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @tests.nil? + true + end + + # Custom attribute writer method with validation + # @param tests [Object] Object to be assigned + # @!visibility private + def tests=(tests) + if tests.nil? + fail ArgumentError, 'invalid value for "tests", tests cannot be nil.' + end + @tests = tests + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + tests == o.tests && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [tests, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_request_data.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_request_data.rb new file mode 100644 index 000000000000..8e18b01e4d90 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_request_data.rb @@ -0,0 +1,144 @@ +=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 JSON:API data for updating flaky test states. + class UpdateFlakyTestsRequestData + include BaseGenericModel + + # Attributes for updating flaky test states. + attr_reader :attributes + + # The definition of `UpdateFlakyTestsRequestDataType` object. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'UpdateFlakyTestsRequestAttributes', + :'type' => :'UpdateFlakyTestsRequestDataType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateFlakyTestsRequestData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_request_data_type.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_request_data_type.rb new file mode 100644 index 000000000000..7b1f29ad9a1e --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_request_data_type.rb @@ -0,0 +1,26 @@ +=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 definition of `UpdateFlakyTestsRequestDataType` object. + class UpdateFlakyTestsRequestDataType + include BaseEnumModel + + UPDATE_FLAKY_TEST_STATE_REQUEST = "update_flaky_test_state_request".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_request_test.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_request_test.rb new file mode 100644 index 000000000000..28a667b05246 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_request_test.rb @@ -0,0 +1,144 @@ +=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 + # Details of what tests to update and their new attributes. + class UpdateFlakyTestsRequestTest + include BaseGenericModel + + # The ID of the flaky test. This is the same ID returned by the Search flaky tests endpoint and corresponds to the test_fingerprint_fqn field in test run events. + attr_reader :id + + # The new state to set for the flaky test. + attr_reader :new_state + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'id' => :'id', + :'new_state' => :'new_state' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'id' => :'String', + :'new_state' => :'UpdateFlakyTestsRequestTestNewState' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateFlakyTestsRequestTest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'new_state') + self.new_state = attributes[:'new_state'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @id.nil? + return false if @new_state.nil? + true + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param new_state [Object] Object to be assigned + # @!visibility private + def new_state=(new_state) + if new_state.nil? + fail ArgumentError, 'invalid value for "new_state", new_state cannot be nil.' + end + @new_state = new_state + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + new_state == o.new_state && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [id, new_state, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_request_test_new_state.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_request_test_new_state.rb new file mode 100644 index 000000000000..865a5aee63ab --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_request_test_new_state.rb @@ -0,0 +1,29 @@ +=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 new state to set for the flaky test. + class UpdateFlakyTestsRequestTestNewState + include BaseEnumModel + + ACTIVE = "active".freeze + QUARANTINED = "quarantined".freeze + DISABLED = "disabled".freeze + FIXED = "fixed".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_response.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_response.rb new file mode 100644 index 000000000000..42db0ba65259 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_response.rb @@ -0,0 +1,105 @@ +=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 + # Response object for updating flaky test states. + class UpdateFlakyTestsResponse + include BaseGenericModel + + # Summary of the update operations. Tells whether a test succeeded or failed to be updated. + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'UpdateFlakyTestsResponseData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateFlakyTestsResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_response_attributes.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_response_attributes.rb new file mode 100644 index 000000000000..1a74d27bac52 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_response_attributes.rb @@ -0,0 +1,146 @@ +=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 + # Attributes for the update flaky test state response. + class UpdateFlakyTestsResponseAttributes + include BaseGenericModel + + # `True` if any errors occurred during the update operations. `False` if all tests succeeded to be updated. + attr_reader :has_errors + + # Results of the update operation for each test. + attr_reader :results + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'has_errors' => :'has_errors', + :'results' => :'results' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'has_errors' => :'Boolean', + :'results' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateFlakyTestsResponseAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'has_errors') + self.has_errors = attributes[:'has_errors'] + end + + if attributes.key?(:'results') + if (value = attributes[:'results']).is_a?(Array) + self.results = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @has_errors.nil? + return false if @results.nil? + true + end + + # Custom attribute writer method with validation + # @param has_errors [Object] Object to be assigned + # @!visibility private + def has_errors=(has_errors) + if has_errors.nil? + fail ArgumentError, 'invalid value for "has_errors", has_errors cannot be nil.' + end + @has_errors = has_errors + end + + # Custom attribute writer method with validation + # @param results [Object] Object to be assigned + # @!visibility private + def results=(results) + if results.nil? + fail ArgumentError, 'invalid value for "results", results cannot be nil.' + end + @results = results + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + has_errors == o.has_errors && + results == o.results && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [has_errors, results, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_response_data.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_response_data.rb new file mode 100644 index 000000000000..78c00164eaec --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_response_data.rb @@ -0,0 +1,125 @@ +=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 + # Summary of the update operations. Tells whether a test succeeded or failed to be updated. + class UpdateFlakyTestsResponseData + include BaseGenericModel + + # Attributes for the update flaky test state response. + attr_accessor :attributes + + # The ID of the response. + attr_accessor :id + + # The definition of `UpdateFlakyTestsResponseDataType` object. + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'UpdateFlakyTestsResponseAttributes', + :'id' => :'String', + :'type' => :'UpdateFlakyTestsResponseDataType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateFlakyTestsResponseData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_response_data_type.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_response_data_type.rb new file mode 100644 index 000000000000..f0402fa57a61 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_response_data_type.rb @@ -0,0 +1,26 @@ +=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 definition of `UpdateFlakyTestsResponseDataType` object. + class UpdateFlakyTestsResponseDataType + include BaseEnumModel + + UPDATE_FLAKY_TEST_STATE_RESPONSE = "update_flaky_test_state_response".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/update_flaky_tests_response_result.rb b/lib/datadog_api_client/v2/models/update_flaky_tests_response_result.rb new file mode 100644 index 000000000000..3dab004db158 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_flaky_tests_response_result.rb @@ -0,0 +1,154 @@ +=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 + # Result of updating a single flaky test state. + class UpdateFlakyTestsResponseResult + include BaseGenericModel + + # Error message if the update failed. + attr_accessor :error + + # The ID of the flaky test from the request. This is the same ID returned by the Search flaky tests endpoint and corresponds to the test_fingerprint_fqn field in test run events. + attr_reader :id + + # `True` if the update was successful, `False` if there were any errors. + attr_reader :success + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'error' => :'error', + :'id' => :'id', + :'success' => :'success' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'error' => :'String', + :'id' => :'String', + :'success' => :'Boolean' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateFlakyTestsResponseResult` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'success') + self.success = attributes[:'success'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @id.nil? + return false if @success.nil? + true + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param success [Object] Object to be assigned + # @!visibility private + def success=(success) + if success.nil? + fail ArgumentError, 'invalid value for "success", success cannot be nil.' + end + @success = success + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + error == o.error && + id == o.id && + success == o.success && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [error, id, success, additional_properties].hash + end + end +end