Class: DatadogAPIClient::V2::SoftwareCatalogAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog_api_client/v2/api/software_catalog_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = DatadogAPIClient::APIClient.default) ⇒ SoftwareCatalogAPI

Returns a new instance of SoftwareCatalogAPI.



22
23
24
# File 'lib/datadog_api_client/v2/api/software_catalog_api.rb', line 22

def initialize(api_client = DatadogAPIClient::APIClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



20
21
22
# File 'lib/datadog_api_client/v2/api/software_catalog_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

#delete_catalog_entity(entity_id, opts = {}) ⇒ Object

Delete a single entity.



29
30
31
32
# File 'lib/datadog_api_client/v2/api/software_catalog_api.rb', line 29

def delete_catalog_entity(entity_id, opts = {})
  delete_catalog_entity_with_http_info(entity_id, opts)
  nil
end

#delete_catalog_entity_with_http_info(entity_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete a single entity.

Delete a single entity in Software Catalog.

Parameters:

  • entity_id (String)

    UUID or Entity Ref.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/datadog_api_client/v2/api/software_catalog_api.rb', line 41

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

#list_catalog_entity(opts = {}) ⇒ Object

Get a list of entities.



94
95
96
97
# File 'lib/datadog_api_client/v2/api/software_catalog_api.rb', line 94

def list_catalog_entity(opts = {})
  data, _status_code, _headers = list_catalog_entity_with_http_info(opts)
  data
end

#list_catalog_entity_with_http_info(opts = {}) ⇒ Array<(ListEntityCatalogResponse, Integer, Hash)>

Get a list of entities.

Get a list of entities from Software Catalog.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page_offset (Integer)

    Specific offset to use as the beginning of the returned page.

  • :page_limit (Integer)

    Maximum number of entities in the response.

  • :filter_id (String)

    Filter entities by UUID.

  • :filter_ref (String)

    Filter entities by reference

  • :filter_name (String)

    Filter entities by name.

  • :filter_kind (String)

    Filter entities by kind.

  • :filter_owner (String)

    Filter entities by owner.

  • :filter_relation_type (RelationType)

    Filter entities by relation type.

  • :filter_exclude_snapshot (String)

    Filter entities by excluding snapshotted entities.

  • :include (IncludeType)

    Include relationship data.

Returns:

  • (Array<(ListEntityCatalogResponse, Integer, Hash)>)

    ListEntityCatalogResponse data, response status code and response headers



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/datadog_api_client/v2/api/software_catalog_api.rb', line 115

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

#list_catalog_entity_with_pagination(opts = {}) {|EntityData| ... } ⇒ Object

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 }

Yields:



186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/datadog_api_client/v2/api/software_catalog_api.rb', line 186

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

#upsert_catalog_entity(body, opts = {}) ⇒ Object

Create or update entities.



204
205
206
207
# File 'lib/datadog_api_client/v2/api/software_catalog_api.rb', line 204

def upsert_catalog_entity(body, opts = {})
  data, _status_code, _headers = upsert_catalog_entity_with_http_info(body, opts)
  data
end

#upsert_catalog_entity_with_http_info(body, opts = {}) ⇒ Array<(UpsertCatalogEntityResponse, Integer, Hash)>

Create or update entities.

Create or update entities in Software Catalog.

Parameters:

Returns:

  • (Array<(UpsertCatalogEntityResponse, Integer, Hash)>)

    UpsertCatalogEntityResponse data, response status code and response headers



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/datadog_api_client/v2/api/software_catalog_api.rb', line 216

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