class ApprovalApiClient::TemplateApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/insights-approval-api-client/api/template_api.rb, line 19
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

list_templates(opts = {}) click to toggle source

Return all templates, only available for admin Return all templates @param [Hash] opts the optional parameters @option opts [Integer] :limit How many items to return at one time (max 1000) (default to 100) @option opts [Integer] :offset Starting Offset (default to 0) @option opts [Object] :filter Filter for querying collections. @option opts [String] :sort_by Parameter to sort collection @return [TemplateCollection]

# File lib/insights-approval-api-client/api/template_api.rb, line 30
def list_templates(opts = {})
  data, _status_code, _headers = list_templates_with_http_info(opts)
  data
end
list_templates_with_http_info(opts = {}) click to toggle source

Return all templates, only available for admin Return all templates @param [Hash] opts the optional parameters @option opts [Integer] :limit How many items to return at one time (max 1000) @option opts [Integer] :offset Starting Offset @option opts [Object] :filter Filter for querying collections. @option opts [String] :sort_by Parameter to sort collection @return [Array<(TemplateCollection, Integer, Hash)>] TemplateCollection data, response status code and response headers

# File lib/insights-approval-api-client/api/template_api.rb, line 43
def list_templates_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.list_templates ...'
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling TemplateApi.list_templates, must be smaller than or equal to 1000.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling TemplateApi.list_templates, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling TemplateApi.list_templates, must be greater than or equal to 0.'
  end

  # resource path
  local_var_path = '/templates'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].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[:body] 

  # return_type
  return_type = opts[:return_type] || 'TemplateCollection' 

  # auth_names
  auth_names = opts[:auth_names] || ['Basic_auth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#list_templates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
show_template(id, opts = {}) click to toggle source

Return a template by given id, only available for admin Return a template by given id @param id [String] Query by id @param [Hash] opts the optional parameters @return [Template]

# File lib/insights-approval-api-client/api/template_api.rb, line 107
def show_template(id, opts = {})
  data, _status_code, _headers = show_template_with_http_info(id, opts)
  data
end
show_template_with_http_info(id, opts = {}) click to toggle source

Return a template by given id, only available for admin Return a template by given id @param id [String] Query by id @param [Hash] opts the optional parameters @return [Array<(Template, Integer, Hash)>] Template data, response status code and response headers

# File lib/insights-approval-api-client/api/template_api.rb, line 117
def show_template_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TemplateApi.show_template ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling TemplateApi.show_template"
  end
  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation && id !~ pattern
    fail ArgumentError, "invalid value for 'id' when calling TemplateApi.show_template, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/templates/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # 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[:body] 

  # return_type
  return_type = opts[:return_type] || 'Template' 

  # auth_names
  auth_names = opts[:auth_names] || ['Basic_auth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TemplateApi#show_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end