Class: AxHub::Client
- Inherits:
-
Object
- Object
- AxHub::Client
- Defined in:
- lib/axhub_sdk.rb,
lib/axhub_sdk/operations.rb
Instance Attribute Summary collapse
-
#apps ⇒ Object
readonly
Returns the value of attribute apps.
-
#audit ⇒ Object
readonly
Returns the value of attribute audit.
-
#authz ⇒ Object
readonly
Returns the value of attribute authz.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#deployments ⇒ Object
readonly
Returns the value of attribute deployments.
-
#gateway ⇒ Object
readonly
Returns the value of attribute gateway.
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
-
#tenants ⇒ Object
readonly
Returns the value of attribute tenants.
Instance Method Summary collapse
-
#__axhub_original_initialize ⇒ Client
A new instance of Client.
-
#initialize(*args, **kwargs) ⇒ Client
constructor
A new instance of Client.
- #redacted_token ⇒ Object
- #request(operation_id, path_params: {}, query: {}, body: nil) ⇒ Object
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
#apps ⇒ Object (readonly)
Returns the value of attribute apps.
229 230 231 |
# File 'lib/axhub_sdk.rb', line 229 def apps @apps end |
#audit ⇒ Object (readonly)
Returns the value of attribute audit.
19 20 21 |
# File 'lib/axhub_sdk/operations.rb', line 19 def audit @audit end |
#authz ⇒ Object (readonly)
Returns the value of attribute authz.
19 20 21 |
# File 'lib/axhub_sdk/operations.rb', line 19 def authz @authz end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
229 230 231 |
# File 'lib/axhub_sdk.rb', line 229 def base_url @base_url end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
19 20 21 |
# File 'lib/axhub_sdk/operations.rb', line 19 def data @data end |
#deployments ⇒ Object (readonly)
Returns the value of attribute deployments.
19 20 21 |
# File 'lib/axhub_sdk/operations.rb', line 19 def deployments @deployments end |
#gateway ⇒ Object (readonly)
Returns the value of attribute gateway.
19 20 21 |
# File 'lib/axhub_sdk/operations.rb', line 19 def gateway @gateway end |
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
19 20 21 |
# File 'lib/axhub_sdk/operations.rb', line 19 def identity @identity end |
#tenants ⇒ Object (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_initialize ⇒ Client
Returns 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_token ⇒ Object
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
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 |