Class: Sophos::Client

Inherits:
API
  • Object
show all
Includes:
Helper, Partner
Defined in:
lib/sophos/client.rb,
lib/sophos/client/common.rb,
lib/sophos/client/helper.rb,
lib/sophos/client/partner.rb,
lib/sophos/client/endpoint.rb

Overview

Generate generic api methods

Direct Known Subclasses

TenantClient

Defined Under Namespace

Modules: Common, Endpoint, Helper, Partner

Constant Summary

Constants included from Configuration

Sophos::Configuration::DEFAULT_ENDPOINT, Sophos::Configuration::DEFAULT_ID_ENDPOINT, Sophos::Configuration::DEFAULT_PAGE_SIZE, Sophos::Configuration::DEFAULT_PAGINATION, Sophos::Configuration::DEFAULT_UA, Sophos::Configuration::VALID_OPTIONS_KEYS

Instance Method Summary collapse

Methods included from Helper

common_url, def_api_call, endpoint_url, partner_url, sanitize, url

Methods included from Partner

#admin_role_assignment, #admin_role_assignments, #billing_usage, #permission_sets

Methods inherited from API

#config, #initialize

Methods included from Authentication

#auth_token

Methods included from Configuration

extended, #options, #reset

Constructor Details

This class inherits a constructor from Sophos::API

Instance Method Details

#client(tenant) ⇒ TenantClient

get client to access api host for given tenant

Returns:



14
15
16
# File 'lib/sophos/client.rb', line 14

def client(tenant)
  tenant_client(tenant.apiHost, tenant.id) if tenant
end

#tenant_client(api_host, tenant_id) ⇒ TenantClient

get teannt client to access api host for given tenant id

Returns:



20
21
22
23
24
25
26
27
28
# File 'lib/sophos/client.rb', line 20

def tenant_client( api_host, tenant_id )
  # create client and copy access_token and set default headers
  TenantClient.new(self.config.merge({
    access_token: access_token,
    endpoint: api_host,
    tenant_id: tenant_id,
    connection_options: { headers: { 'X-Tenant-ID': tenant_id } }
  }))
end