Class: AxHub::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/axhub_sdk.rb,
lib/axhub_sdk/operations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, **kwargs) ⇒ Client

Returns a new instance of Client.



230
231
232
# File 'lib/axhub_sdk.rb', line 230

def initialize(base_url: DEFAULT_BASE_URL, token: nil, token_type: nil, default_tenant_id: nil, default_tenant_slug: nil, timeout_seconds: 30)
  @base_url = base_url.sub(%r{/$}, ''); @token = token; @token_type = token_type&.to_sym; @default_tenant_id = default_tenant_id; @default_tenant_slug = default_tenant_slug; @timeout_seconds = timeout_seconds; @apps = AppsClient.new(self)
end

Instance Attribute Details

#appsObject (readonly)

Returns the value of attribute apps.



229
230
231
# File 'lib/axhub_sdk.rb', line 229

def apps
  @apps
end

#auditObject (readonly)

Returns the value of attribute audit.



19
20
21
# File 'lib/axhub_sdk/operations.rb', line 19

def audit
  @audit
end

#authzObject (readonly)

Returns the value of attribute authz.



19
20
21
# File 'lib/axhub_sdk/operations.rb', line 19

def authz
  @authz
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



229
230
231
# File 'lib/axhub_sdk.rb', line 229

def base_url
  @base_url
end

#dataObject (readonly)

Returns the value of attribute data.



19
20
21
# File 'lib/axhub_sdk/operations.rb', line 19

def data
  @data
end

#deploymentsObject (readonly)

Returns the value of attribute deployments.



19
20
21
# File 'lib/axhub_sdk/operations.rb', line 19

def deployments
  @deployments
end

#gatewayObject (readonly)

Returns the value of attribute gateway.



19
20
21
# File 'lib/axhub_sdk/operations.rb', line 19

def gateway
  @gateway
end

#identityObject (readonly)

Returns the value of attribute identity.



19
20
21
# File 'lib/axhub_sdk/operations.rb', line 19

def identity
  @identity
end

#tenantsObject (readonly)

Returns the value of attribute tenants.



19
20
21
# File 'lib/axhub_sdk/operations.rb', line 19

def tenants
  @tenants
end

Instance Method Details

#__axhub_original_initializeClient

Returns a new instance of Client.

Returns:

  • (Client)

    a new instance of Client



20
21
22
# File 'lib/axhub_sdk/operations.rb', line 20

def initialize(base_url: DEFAULT_BASE_URL, token: nil, token_type: nil, default_tenant_id: nil, default_tenant_slug: nil, timeout_seconds: 30)
  @base_url = base_url.sub(%r{/$}, ''); @token = token; @token_type = token_type&.to_sym; @default_tenant_id = default_tenant_id; @default_tenant_slug = default_tenant_slug; @timeout_seconds = timeout_seconds; @apps = AppsClient.new(self)
end

#redacted_tokenObject



233
234
235
# File 'lib/axhub_sdk.rb', line 233

def redacted_token
  @token.nil? || @token.empty? ? '' : '***REDACTED***'
end

#request(operation_id, path_params: {}, query: {}, body: nil) ⇒ Object

Raises:



236
237
238
239
240
241
242
243
244
245
# File 'lib/axhub_sdk.rb', line 236

def request(operation_id, path_params: {}, query: {}, body: nil)
  route = ROUTE_BY_OP.fetch(operation_id); path = route['path'].dup; path_params.each { |k, v| path.gsub!("{#{k}}", URI.encode_www_form_component(v.to_s)) }; raise Error.new(category: 'validation', code: 'required', message: 'missing path parameter') if path.include?(123.chr) || path.include?(125.chr)
  uri = URI(@base_url + path); uri.query = URI.encode_www_form(query) unless query.empty?
  req_class = Net::HTTP.const_get(route['method'].capitalize); req = req_class.new(uri); req['X-Request-ID'] = request_id
  if body
    req['Content-Type'] = 'application/json'
    req.body = JSON.generate(body)
  end
  _send(req, uri, camelize: true)
end