=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 'cgi' module DatadogAPIClient::V2 class SoftwareCatalogAPI attr_accessor :api_client def initialize(api_client = DatadogAPIClient::APIClient.default) @api_client = api_client end # Delete a single entity. # # @see #delete_catalog_entity_with_http_info def delete_catalog_entity(entity_id, opts = {}) delete_catalog_entity_with_http_info(entity_id, opts) nil end # Delete a single entity. # # Delete a single entity in Software Catalog. # # @param entity_id [String] UUID or Entity Ref. # @param opts [Hash] the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def delete_catalog_entity_with_http_info(entity_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SoftwareCatalogAPI.delete_catalog_entity ...' end # verify the required parameter 'entity_id' is set if @api_client.config.client_side_validation && entity_id.nil? fail ArgumentError, "Missing the required parameter 'entity_id' when calling SoftwareCatalogAPI.delete_catalog_entity" end # resource path local_var_path = '/api/v2/catalog/entity/{entity_id}'.sub('{entity_id}', CGI.escape(entity_id.to_s).gsub('%2F', '/')) # 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(['*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :delete_catalog_entity, :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::Delete, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: SoftwareCatalogAPI#delete_catalog_entity\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a list of entities. # # @see #list_catalog_entity_with_http_info def list_catalog_entity(opts = {}) data, _status_code, _headers = list_catalog_entity_with_http_info(opts) data end # Get a list of entities. # # Get a list of entities from Software Catalog. # # @param opts [Hash] the optional parameters # @option opts [Integer] :page_offset Specific offset to use as the beginning of the returned page. # @option opts [Integer] :page_limit Maximum number of entities in the response. # @option opts [String] :filter_id Filter entities by UUID. # @option opts [String] :filter_ref Filter entities by reference # @option opts [String] :filter_name Filter entities by name. # @option opts [String] :filter_kind Filter entities by kind. # @option opts [String] :filter_owner Filter entities by owner. # @option opts [RelationType] :filter_relation_type Filter entities by relation type. # @option opts [String] :filter_exclude_snapshot Filter entities by excluding snapshotted entities. # @option opts [IncludeType] :include Include relationship data. # @return [Array<(ListEntityCatalogResponse, Integer, Hash)>] ListEntityCatalogResponse data, response status code and response headers def list_catalog_entity_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SoftwareCatalogAPI.list_catalog_entity ...' end allowable_values = ['RelationTypeOwns', 'RelationTypeOwnedBy', 'RelationTypeDependsOn', 'RelationTypeDependencyOf', 'RelationTypePartsOf', 'RelationTypeHasPart', 'RelationTypeOtherOwns', 'RelationTypeOtherOwnedBy', 'RelationTypeImplementedBy', 'RelationTypeImplements'] if @api_client.config.client_side_validation && opts[:'filter_relation_type'] && !allowable_values.include?(opts[:'filter_relation_type']) fail ArgumentError, "invalid value for \"filter_relation_type\", must be one of #{allowable_values}" end allowable_values = ['schema', 'raw_schema', 'oncall', 'incident', 'relation'] if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include']) fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}" end # resource path local_var_path = '/api/v2/catalog/entity' # query parameters query_params = opts[:query_params] || {} query_params[:'page[offset]'] = opts[:'page_offset'] if !opts[:'page_offset'].nil? query_params[:'page[limit]'] = opts[:'page_limit'] if !opts[:'page_limit'].nil? query_params[:'filter[id]'] = opts[:'filter_id'] if !opts[:'filter_id'].nil? query_params[:'filter[ref]'] = opts[:'filter_ref'] if !opts[:'filter_ref'].nil? query_params[:'filter[name]'] = opts[:'filter_name'] if !opts[:'filter_name'].nil? query_params[:'filter[kind]'] = opts[:'filter_kind'] if !opts[:'filter_kind'].nil? query_params[:'filter[owner]'] = opts[:'filter_owner'] if !opts[:'filter_owner'].nil? query_params[:'filter[relation][type]'] = opts[:'filter_relation_type'] if !opts[:'filter_relation_type'].nil? query_params[:'filter[exclude_snapshot]'] = opts[:'filter_exclude_snapshot'] if !opts[:'filter_exclude_snapshot'].nil? query_params[:'include'] = opts[:'include'] if !opts[:'include'].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] || 'ListEntityCatalogResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :list_catalog_entity, :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: SoftwareCatalogAPI#list_catalog_entity\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a list of entities. # # Provide a paginated version of {#list_catalog_entity}, returning all items. # # To use it you need to use a block: list_catalog_entity_with_pagination { |item| p item } # # @yield [EntityData] Paginated items def list_catalog_entity_with_pagination(opts = {}) api_version = "V2" page_size = @api_client.get_attribute_from_path(opts, "page_limit", 100) @api_client.set_attribute_from_path(api_version, opts, "page_limit", Integer, page_size) @api_client.set_attribute_from_path(api_version, opts, "page_offset", Integer, 0) while true do response = list_catalog_entity(opts) @api_client.get_attribute_from_path(response, "data").each { |item| yield(item) } if @api_client.get_attribute_from_path(response, "data").length < page_size break end @api_client.set_attribute_from_path(api_version, opts, "page_offset", Integer, @api_client.get_attribute_from_path(opts, "page_offset", 0) + 1) end end # Create or update entities. # # @see #upsert_catalog_entity_with_http_info def upsert_catalog_entity(body, opts = {}) data, _status_code, _headers = upsert_catalog_entity_with_http_info(body, opts) data end # Create or update entities. # # Create or update entities in Software Catalog. # # @param body [UpsertCatalogEntityRequest] Entity YAML or JSON. # @param opts [Hash] the optional parameters # @return [Array<(UpsertCatalogEntityResponse, Integer, Hash)>] UpsertCatalogEntityResponse data, response status code and response headers def upsert_catalog_entity_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SoftwareCatalogAPI.upsert_catalog_entity ...' 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 SoftwareCatalogAPI.upsert_catalog_entity" end # resource path local_var_path = '/api/v2/catalog/entity' # 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] || 'UpsertCatalogEntityResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :upsert_catalog_entity, :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::Post, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: SoftwareCatalogAPI#upsert_catalog_entity\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end