diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 07a00c9a7f36..7a0a9aa0fec1 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -41461,6 +41461,39 @@ components: example: "/api/v2/scorecard/rules?page%5Blimit%5D=2&page%5Boffset%5D=2&page%5Bsize%5D=2" type: string type: object + ListScorecardScoresMeta: + description: Pagination metadata for scores. + properties: + count: + description: The number of results returned in this page. + format: int64 + type: integer + limit: + description: The page limit. + format: int64 + type: integer + offset: + description: The page offset. + format: int64 + type: integer + total: + description: The total number of results. + format: int64 + type: integer + type: object + ListScorecardScoresResponse: + description: A list of scorecard scores for a given aggregation type. + properties: + data: + description: Array of score objects. + items: + $ref: "#/components/schemas/ScorecardScoreData" + type: array + links: + $ref: "#/components/schemas/ListRulesResponseLinks" + meta: + $ref: "#/components/schemas/ListScorecardScoresMeta" + type: object ListScorecardsResponse: description: Response containing a list of scorecards. properties: @@ -62579,6 +62612,119 @@ components: type: string x-enum-varnames: - SCORECARD + ScorecardScoreAttributes: + description: Attributes of a scorecard score. + properties: + aggregation: + $ref: "#/components/schemas/ScorecardScoresAggregation" + denominator: + description: The denominator used to compute the score ratio. + format: int64 + type: integer + level: + description: The maturity level of the associated rule. + format: int64 + type: integer + numerator: + description: The numerator used to compute the score ratio. + format: int64 + type: integer + score: + description: The computed score ratio (numerator/denominator), from 0 to 1. + format: double + type: number + total_entities: + description: The total number of entities evaluated. + format: int64 + type: integer + total_fail: + description: The number of rules that failed. + format: int64 + type: integer + total_no_data: + description: The number of rules with no data. + format: int64 + type: integer + total_pass: + description: The number of rules that passed. + format: int64 + type: integer + total_skip: + description: The number of rules that were skipped. + format: int64 + type: integer + type: object + ScorecardScoreData: + description: A scorecard score object for a single entity, rule, scorecard, service, or team. + properties: + attributes: + $ref: "#/components/schemas/ScorecardScoreAttributes" + id: + description: The ID of the entity or resource being scored. + example: "" + type: string + relationships: + $ref: "#/components/schemas/ScorecardScoreRelationships" + type: + $ref: "#/components/schemas/ScorecardScoreDataType" + required: + - id + - type + type: object + ScorecardScoreDataType: + default: score + description: The JSON:API resource type. + enum: [score] + example: score + type: string + x-enum-varnames: + - SCORE + ScorecardScoreRelationshipData: + description: A relationship data object for a score. + properties: + id: + description: The ID of the related resource. + example: "" + type: string + type: + description: The type of the related resource. + example: "" + type: string + required: + - id + - type + type: object + ScorecardScoreRelationshipItem: + description: A relationship item for a score. + properties: + data: + $ref: "#/components/schemas/ScorecardScoreRelationshipData" + type: object + ScorecardScoreRelationships: + description: Relationships for a scorecard score, depending on the aggregation type. + properties: + entity: + $ref: "#/components/schemas/ScorecardScoreRelationshipItem" + rule: + $ref: "#/components/schemas/ScorecardScoreRelationshipItem" + scorecard: + $ref: "#/components/schemas/ScorecardScoreRelationshipItem" + service: + $ref: "#/components/schemas/ScorecardScoreRelationshipItem" + team: + $ref: "#/components/schemas/ScorecardScoreRelationshipItem" + type: object + ScorecardScoresAggregation: + description: Dimension to group scores by. + enum: [by-entity, by-rule, by-scorecard, by-team, by-kind] + example: by-entity + type: string + x-enum-varnames: + - BY_ENTITY + - BY_RULE + - BY_SCORECARD + - BY_TEAM + - BY_KIND ScorecardType: default: scorecard description: The JSON:API type for scorecard. @@ -128170,6 +128316,127 @@ paths: summary: List all scorecards tags: - Scorecards + /api/v2/scorecard/scores/{aggregation}: + get: + description: Returns a list of scorecard scores for each aggregation type, with score breakdowns. + operationId: ListScorecardScores + parameters: + - description: The type of scores being requested. + in: path + name: aggregation + required: true + schema: + $ref: "#/components/schemas/ScorecardScoresAggregation" + - description: Filter scores by an entity query string. + in: query + name: filter[entity][query] + required: false + schema: + type: string + - description: Filter scores by rule ID(s), comma-separated. + in: query + name: filter[rule][id] + required: false + schema: + type: string + - description: Filter scores by rule name. + in: query + name: filter[rule][name] + required: false + schema: + type: string + - description: Filter scores by rule level(s), comma-separated. + in: query + name: filter[rule][level] + required: false + schema: + type: string + - description: Filter scores by scorecard ID(s), comma-separated. + in: query + name: filter[rule][scorecard_id] + required: false + schema: + type: string + - description: Filter scores to show only custom rules. + in: query + name: filter[rule][is_custom] + required: false + schema: + type: boolean + - description: Filter scores to show only enabled rules. + in: query + name: filter[rule][is_enabled] + required: false + schema: + type: boolean + - description: "Sort scores by field. Use a hyphen prefix for descending order. Options: score, numerator, denominator, total_pass, total_fail, total_skip, total_no_data." + in: query + name: sort + required: false + schema: + type: string + - description: Offset for pagination. + in: query + name: page[offset] + required: false + schema: + default: 0 + type: integer + - description: Number of scores to return. Max is 1000. + in: query + name: page[limit] + required: false + schema: + default: 100 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + aggregation: by-entity + denominator: 4 + numerator: 3 + score: 0.75 + total_fail: 1 + total_no_data: 0 + total_pass: 3 + total_skip: 0 + id: service:my-service + relationships: + entity: + data: + id: service:my-service + type: entity + type: score + links: + next: /api/v2/scorecard/scores/by-entity?page[offset]=100&page[limit]=100 + meta: + count: 1 + limit: 100 + offset: 0 + total: 42 + schema: + $ref: "#/components/schemas/ListScorecardScoresResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + summary: List all scores + tags: + - Scorecards /api/v2/seats/users: delete: description: |- diff --git a/examples/v2/scorecards/ListScorecardScores.rb b/examples/v2/scorecards/ListScorecardScores.rb new file mode 100644 index 000000000000..8358a5f4fd8d --- /dev/null +++ b/examples/v2/scorecards/ListScorecardScores.rb @@ -0,0 +1,5 @@ +# List all scores returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::ScorecardsAPI.new +p api_instance.list_scorecard_scores(ScorecardScoresAggregation::BY_ENTITY) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 7438c2450d1c..555a5f27540e 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -4001,6 +4001,19 @@ "filter_scorecard_name" => "String", "filter_scorecard_description" => "String", }, + "v2.ListScorecardScores" => { + "aggregation" => "ScorecardScoresAggregation", + "filter_entity_query" => "String", + "filter_rule_id" => "String", + "filter_rule_name" => "String", + "filter_rule_level" => "String", + "filter_rule_scorecard_id" => "String", + "filter_rule_is_custom" => "Boolean", + "filter_rule_is_enabled" => "Boolean", + "sort" => "String", + "page_offset" => "Integer", + "page_limit" => "Integer", + }, "v2.UnassignSeatsUser" => { "body" => "UnassignSeatsUserRequest", }, diff --git a/features/v2/scorecards.feature b/features/v2/scorecards.feature index 750948d89919..e932599c677b 100644 --- a/features/v2/scorecards.feature +++ b/features/v2/scorecards.feature @@ -183,6 +183,20 @@ Feature: Scorecards When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/service-catalog + Scenario: List all scores returns "Bad Request" response + Given new "ListScorecardScores" request + And request contains "aggregation" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: List all scores returns "OK" response + Given new "ListScorecardScores" request + And request contains "aggregation" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/service-catalog Scenario: Update Scorecard outcomes asynchronously returns "Accepted" response Given there is a valid "create_scorecard_rule" in the system diff --git a/features/v2/undo.json b/features/v2/undo.json index 049acf0531b7..998d5322abb8 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -5276,6 +5276,12 @@ "type": "safe" } }, + "ListScorecardScores": { + "tag": "Scorecards", + "undo": { + "type": "safe" + } + }, "UnassignSeatsUser": { "tag": "Seats", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 8864ce914837..f90fff7b23b5 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -3487,6 +3487,8 @@ def overrides "v2.list_rules_response" => "ListRulesResponse", "v2.list_rules_response_data_item" => "ListRulesResponseDataItem", "v2.list_rules_response_links" => "ListRulesResponseLinks", + "v2.list_scorecard_scores_meta" => "ListScorecardScoresMeta", + "v2.list_scorecard_scores_response" => "ListScorecardScoresResponse", "v2.list_scorecards_response" => "ListScorecardsResponse", "v2.list_security_findings_response" => "ListSecurityFindingsResponse", "v2.list_tags_response" => "ListTagsResponse", @@ -5057,6 +5059,13 @@ def overrides "v2.scorecard_list_response_attributes" => "ScorecardListResponseAttributes", "v2.scorecard_list_response_data" => "ScorecardListResponseData", "v2.scorecard_list_type" => "ScorecardListType", + "v2.scorecard_score_attributes" => "ScorecardScoreAttributes", + "v2.scorecard_score_data" => "ScorecardScoreData", + "v2.scorecard_score_data_type" => "ScorecardScoreDataType", + "v2.scorecard_score_relationship_data" => "ScorecardScoreRelationshipData", + "v2.scorecard_score_relationship_item" => "ScorecardScoreRelationshipItem", + "v2.scorecard_score_relationships" => "ScorecardScoreRelationships", + "v2.scorecard_scores_aggregation" => "ScorecardScoresAggregation", "v2.scorecard_type" => "ScorecardType", "v2.search_issues_include_query_parameter_item" => "SearchIssuesIncludeQueryParameterItem", "v2.seat_assignments_data_type" => "SeatAssignmentsDataType", diff --git a/lib/datadog_api_client/v2/api/scorecards_api.rb b/lib/datadog_api_client/v2/api/scorecards_api.rb index 4fe588c15742..61048a0084a5 100644 --- a/lib/datadog_api_client/v2/api/scorecards_api.rb +++ b/lib/datadog_api_client/v2/api/scorecards_api.rb @@ -774,6 +774,96 @@ def list_scorecards_with_http_info(opts = {}) return data, status_code, headers end + # List all scores. + # + # @see #list_scorecard_scores_with_http_info + def list_scorecard_scores(aggregation, opts = {}) + data, _status_code, _headers = list_scorecard_scores_with_http_info(aggregation, opts) + data + end + + # List all scores. + # + # Returns a list of scorecard scores for each aggregation type, with score breakdowns. + # + # @param aggregation [ScorecardScoresAggregation] The type of scores being requested. + # @param opts [Hash] the optional parameters + # @option opts [String] :filter_entity_query Filter scores by an entity query string. + # @option opts [String] :filter_rule_id Filter scores by rule ID(s), comma-separated. + # @option opts [String] :filter_rule_name Filter scores by rule name. + # @option opts [String] :filter_rule_level Filter scores by rule level(s), comma-separated. + # @option opts [String] :filter_rule_scorecard_id Filter scores by scorecard ID(s), comma-separated. + # @option opts [Boolean] :filter_rule_is_custom Filter scores to show only custom rules. + # @option opts [Boolean] :filter_rule_is_enabled Filter scores to show only enabled rules. + # @option opts [String] :sort Sort scores by field. Use a hyphen prefix for descending order. Options: score, numerator, denominator, total_pass, total_fail, total_skip, total_no_data. + # @option opts [Integer] :page_offset Offset for pagination. + # @option opts [Integer] :page_limit Number of scores to return. Max is 1000. + # @return [Array<(ListScorecardScoresResponse, Integer, Hash)>] ListScorecardScoresResponse data, response status code and response headers + def list_scorecard_scores_with_http_info(aggregation, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ScorecardsAPI.list_scorecard_scores ...' + end + # verify the required parameter 'aggregation' is set + if @api_client.config.client_side_validation && aggregation.nil? + fail ArgumentError, "Missing the required parameter 'aggregation' when calling ScorecardsAPI.list_scorecard_scores" + end + # verify enum value + allowable_values = ['by-entity', 'by-rule', 'by-scorecard', 'by-team', 'by-kind'] + if @api_client.config.client_side_validation && !allowable_values.include?(aggregation) + fail ArgumentError, "invalid value for \"aggregation\", must be one of #{allowable_values}" + end + # resource path + local_var_path = '/api/v2/scorecard/scores/{aggregation}'.sub('{aggregation}', CGI.escape(aggregation.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'filter[entity][query]'] = opts[:'filter_entity_query'] if !opts[:'filter_entity_query'].nil? + query_params[:'filter[rule][id]'] = opts[:'filter_rule_id'] if !opts[:'filter_rule_id'].nil? + query_params[:'filter[rule][name]'] = opts[:'filter_rule_name'] if !opts[:'filter_rule_name'].nil? + query_params[:'filter[rule][level]'] = opts[:'filter_rule_level'] if !opts[:'filter_rule_level'].nil? + query_params[:'filter[rule][scorecard_id]'] = opts[:'filter_rule_scorecard_id'] if !opts[:'filter_rule_scorecard_id'].nil? + query_params[:'filter[rule][is_custom]'] = opts[:'filter_rule_is_custom'] if !opts[:'filter_rule_is_custom'].nil? + query_params[:'filter[rule][is_enabled]'] = opts[:'filter_rule_is_enabled'] if !opts[:'filter_rule_is_enabled'].nil? + query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? + query_params[:'page[offset]'] = opts[:'page_offset'] if !opts[:'page_offset'].nil? + query_params[:'page[limit]'] = opts[:'page_limit'] if !opts[:'page_limit'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ListScorecardScoresResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_scorecard_scores, + :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::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ScorecardsAPI#list_scorecard_scores\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Update a campaign. # # @see #update_scorecard_campaign_with_http_info diff --git a/lib/datadog_api_client/v2/models/list_scorecard_scores_meta.rb b/lib/datadog_api_client/v2/models/list_scorecard_scores_meta.rb new file mode 100644 index 000000000000..2a53626becda --- /dev/null +++ b/lib/datadog_api_client/v2/models/list_scorecard_scores_meta.rb @@ -0,0 +1,135 @@ +=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 + # Pagination metadata for scores. + class ListScorecardScoresMeta + include BaseGenericModel + + # The number of results returned in this page. + attr_accessor :count + + # The page limit. + attr_accessor :limit + + # The page offset. + attr_accessor :offset + + # The total number of results. + attr_accessor :total + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'count' => :'count', + :'limit' => :'limit', + :'offset' => :'offset', + :'total' => :'total' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'count' => :'Integer', + :'limit' => :'Integer', + :'offset' => :'Integer', + :'total' => :'Integer' + } + 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::ListScorecardScoresMeta` 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?(:'count') + self.count = attributes[:'count'] + end + + if attributes.key?(:'limit') + self.limit = attributes[:'limit'] + end + + if attributes.key?(:'offset') + self.offset = attributes[:'offset'] + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + 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 && + count == o.count && + limit == o.limit && + offset == o.offset && + total == o.total && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [count, limit, offset, total, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/list_scorecard_scores_response.rb b/lib/datadog_api_client/v2/models/list_scorecard_scores_response.rb new file mode 100644 index 000000000000..4fdfe048ec16 --- /dev/null +++ b/lib/datadog_api_client/v2/models/list_scorecard_scores_response.rb @@ -0,0 +1,127 @@ +=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 + # A list of scorecard scores for a given aggregation type. + class ListScorecardScoresResponse + include BaseGenericModel + + # Array of score objects. + attr_accessor :data + + # Links attributes. + attr_accessor :links + + # Pagination metadata for scores. + attr_accessor :meta + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'links' => :'links', + :'meta' => :'meta' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'links' => :'ListRulesResponseLinks', + :'meta' => :'ListScorecardScoresMeta' + } + 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::ListScorecardScoresResponse` 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') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'links') + self.links = attributes[:'links'] + end + + if attributes.key?(:'meta') + self.meta = attributes[:'meta'] + 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 && + links == o.links && + meta == o.meta && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, links, meta, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/scorecard_score_attributes.rb b/lib/datadog_api_client/v2/models/scorecard_score_attributes.rb new file mode 100644 index 000000000000..67ad4e03cf6f --- /dev/null +++ b/lib/datadog_api_client/v2/models/scorecard_score_attributes.rb @@ -0,0 +1,195 @@ +=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 of a scorecard score. + class ScorecardScoreAttributes + include BaseGenericModel + + # Dimension to group scores by. + attr_accessor :aggregation + + # The denominator used to compute the score ratio. + attr_accessor :denominator + + # The maturity level of the associated rule. + attr_accessor :level + + # The numerator used to compute the score ratio. + attr_accessor :numerator + + # The computed score ratio (numerator/denominator), from 0 to 1. + attr_accessor :score + + # The total number of entities evaluated. + attr_accessor :total_entities + + # The number of rules that failed. + attr_accessor :total_fail + + # The number of rules with no data. + attr_accessor :total_no_data + + # The number of rules that passed. + attr_accessor :total_pass + + # The number of rules that were skipped. + attr_accessor :total_skip + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'aggregation' => :'aggregation', + :'denominator' => :'denominator', + :'level' => :'level', + :'numerator' => :'numerator', + :'score' => :'score', + :'total_entities' => :'total_entities', + :'total_fail' => :'total_fail', + :'total_no_data' => :'total_no_data', + :'total_pass' => :'total_pass', + :'total_skip' => :'total_skip' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'aggregation' => :'ScorecardScoresAggregation', + :'denominator' => :'Integer', + :'level' => :'Integer', + :'numerator' => :'Integer', + :'score' => :'Float', + :'total_entities' => :'Integer', + :'total_fail' => :'Integer', + :'total_no_data' => :'Integer', + :'total_pass' => :'Integer', + :'total_skip' => :'Integer' + } + 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::ScorecardScoreAttributes` 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?(:'aggregation') + self.aggregation = attributes[:'aggregation'] + end + + if attributes.key?(:'denominator') + self.denominator = attributes[:'denominator'] + end + + if attributes.key?(:'level') + self.level = attributes[:'level'] + end + + if attributes.key?(:'numerator') + self.numerator = attributes[:'numerator'] + end + + if attributes.key?(:'score') + self.score = attributes[:'score'] + end + + if attributes.key?(:'total_entities') + self.total_entities = attributes[:'total_entities'] + end + + if attributes.key?(:'total_fail') + self.total_fail = attributes[:'total_fail'] + end + + if attributes.key?(:'total_no_data') + self.total_no_data = attributes[:'total_no_data'] + end + + if attributes.key?(:'total_pass') + self.total_pass = attributes[:'total_pass'] + end + + if attributes.key?(:'total_skip') + self.total_skip = attributes[:'total_skip'] + 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 && + aggregation == o.aggregation && + denominator == o.denominator && + level == o.level && + numerator == o.numerator && + score == o.score && + total_entities == o.total_entities && + total_fail == o.total_fail && + total_no_data == o.total_no_data && + total_pass == o.total_pass && + total_skip == o.total_skip && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [aggregation, denominator, level, numerator, score, total_entities, total_fail, total_no_data, total_pass, total_skip, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/scorecard_score_data.rb b/lib/datadog_api_client/v2/models/scorecard_score_data.rb new file mode 100644 index 000000000000..cb3db3eac0a1 --- /dev/null +++ b/lib/datadog_api_client/v2/models/scorecard_score_data.rb @@ -0,0 +1,164 @@ +=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 + # A scorecard score object for a single entity, rule, scorecard, service, or team. + class ScorecardScoreData + include BaseGenericModel + + # Attributes of a scorecard score. + attr_accessor :attributes + + # The ID of the entity or resource being scored. + attr_reader :id + + # Relationships for a scorecard score, depending on the aggregation type. + attr_accessor :relationships + + # The JSON:API resource type. + 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', + :'id' => :'id', + :'relationships' => :'relationships', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'ScorecardScoreAttributes', + :'id' => :'String', + :'relationships' => :'ScorecardScoreRelationships', + :'type' => :'ScorecardScoreDataType' + } + 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::ScorecardScoreData` 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?(:'relationships') + self.relationships = attributes[:'relationships'] + 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 @id.nil? + return false if @type.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 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 && + id == o.id && + relationships == o.relationships && + 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, relationships, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/scorecard_score_data_type.rb b/lib/datadog_api_client/v2/models/scorecard_score_data_type.rb new file mode 100644 index 000000000000..2b5be00e57c7 --- /dev/null +++ b/lib/datadog_api_client/v2/models/scorecard_score_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 JSON:API resource type. + class ScorecardScoreDataType + include BaseEnumModel + + SCORE = "score".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/scorecard_score_relationship_data.rb b/lib/datadog_api_client/v2/models/scorecard_score_relationship_data.rb new file mode 100644 index 000000000000..0d4b93131118 --- /dev/null +++ b/lib/datadog_api_client/v2/models/scorecard_score_relationship_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 + # A relationship data object for a score. + class ScorecardScoreRelationshipData + include BaseGenericModel + + # The ID of the related resource. + attr_reader :id + + # The type of the related resource. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'id' => :'String', + :'type' => :'String' + } + 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::ScorecardScoreRelationshipData` 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?(:'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 @id.nil? + return false if @type.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 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 && + 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 + [id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/scorecard_score_relationship_item.rb b/lib/datadog_api_client/v2/models/scorecard_score_relationship_item.rb new file mode 100644 index 000000000000..4eb636a5911a --- /dev/null +++ b/lib/datadog_api_client/v2/models/scorecard_score_relationship_item.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 + # A relationship item for a score. + class ScorecardScoreRelationshipItem + include BaseGenericModel + + # A relationship data object for a score. + 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' => :'ScorecardScoreRelationshipData' + } + 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::ScorecardScoreRelationshipItem` 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/scorecard_score_relationships.rb b/lib/datadog_api_client/v2/models/scorecard_score_relationships.rb new file mode 100644 index 000000000000..8d0f1fdd26bb --- /dev/null +++ b/lib/datadog_api_client/v2/models/scorecard_score_relationships.rb @@ -0,0 +1,145 @@ +=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 + # Relationships for a scorecard score, depending on the aggregation type. + class ScorecardScoreRelationships + include BaseGenericModel + + # A relationship item for a score. + attr_accessor :entity + + # A relationship item for a score. + attr_accessor :rule + + # A relationship item for a score. + attr_accessor :scorecard + + # A relationship item for a score. + attr_accessor :service + + # A relationship item for a score. + attr_accessor :team + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'entity' => :'entity', + :'rule' => :'rule', + :'scorecard' => :'scorecard', + :'service' => :'service', + :'team' => :'team' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'entity' => :'ScorecardScoreRelationshipItem', + :'rule' => :'ScorecardScoreRelationshipItem', + :'scorecard' => :'ScorecardScoreRelationshipItem', + :'service' => :'ScorecardScoreRelationshipItem', + :'team' => :'ScorecardScoreRelationshipItem' + } + 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::ScorecardScoreRelationships` 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?(:'entity') + self.entity = attributes[:'entity'] + end + + if attributes.key?(:'rule') + self.rule = attributes[:'rule'] + end + + if attributes.key?(:'scorecard') + self.scorecard = attributes[:'scorecard'] + end + + if attributes.key?(:'service') + self.service = attributes[:'service'] + end + + if attributes.key?(:'team') + self.team = attributes[:'team'] + 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 && + entity == o.entity && + rule == o.rule && + scorecard == o.scorecard && + service == o.service && + team == o.team && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [entity, rule, scorecard, service, team, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/scorecard_scores_aggregation.rb b/lib/datadog_api_client/v2/models/scorecard_scores_aggregation.rb new file mode 100644 index 000000000000..e78ce7c52989 --- /dev/null +++ b/lib/datadog_api_client/v2/models/scorecard_scores_aggregation.rb @@ -0,0 +1,30 @@ +=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 + # Dimension to group scores by. + class ScorecardScoresAggregation + include BaseEnumModel + + BY_ENTITY = "by-entity".freeze + BY_RULE = "by-rule".freeze + BY_SCORECARD = "by-scorecard".freeze + BY_TEAM = "by-team".freeze + BY_KIND = "by-kind".freeze + end +end