sophos_central_api 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4001f1778a4cbba03903acb2007aeca8c0840b351baf9654e2e238efb5b1650a
4
- data.tar.gz: fd8467571f6574c9647faab25aa1fc3016a6e1321a179ba5a94de32911cb4fc2
3
+ metadata.gz: ed2be4896987431b40e0fc3b01f61addc9b58485aa3f1157493dadb070a792e2
4
+ data.tar.gz: 848756dcc5fd520b1f5584acad7a9a318caf569cfd4bbef377b9e646fbc6c5f6
5
5
  SHA512:
6
- metadata.gz: df69465b988d9cdc9460ea1e3220eb5e8516386b1c1b6b54d44885c23724c6eac20084053eb7002bc0b1d7bca600e181000879bac27192f0fc2aa4fea14311d1
7
- data.tar.gz: 5766c1061673b8fc638573094111ca4c0023c25d02c58480cc824874187c981e39dce26aeaf93c6ccbacde44b0c862589f973db52789de5d3bb26023dff3ac98
6
+ metadata.gz: b0e6aff68a24b83ae099fbb6d4273dc3cfa918b36223fefca96951b51f352081c50bfeef5f246205daf0ec98281a837f32390d151704340e2f048193479a2bf8
7
+ data.tar.gz: 5aec805aaf3ab8988af7dc8adc50fb4e41564e94bf1cfdfa1fd05b6251bd7ac6a0af0a87fc94b1e619e408b5e1e8266d8ddfa3d86fd2a92bb4dd39c2112731d1
data/.env.template CHANGED
@@ -1,2 +1,3 @@
1
1
  SOPHOS_CLIENT_ID=<SOPHOS_CLIENT_ID>
2
2
  SOPHOS_CLIENT_SECRET=<SOPHOS_CLIENT_SECRET>
3
+ TEST_TENANT=<TENANT ID>
data/CHANGELOG.md CHANGED
@@ -6,3 +6,5 @@
6
6
  ## [0.1.1] - 2024-02-14
7
7
  - Convienience method added to get client for a teannt api host
8
8
 
9
+ ## [0.1.2] - 2024-02-15
10
+ - Fix initialization issue
@@ -7,28 +7,6 @@ module Sophos
7
7
  # @see https://developer.sophos.com/docs/partner-v1/1/overview
8
8
  module Partner
9
9
 
10
- def self.__def_partner_call(method, id_field = nil)
11
- if id_field
12
- self.send(:define_method, method) do |id = nil|
13
- url = partner_url(method)
14
- if id
15
- get(partner_url("#{method}/#{id}"))
16
- else
17
- get_paged(url)
18
- end
19
- end
20
- # strip trailing 's'
21
- singular = method.to_s.chop.to_sym
22
- self.send(:define_method, singular) do |id, params = nil|
23
- get(partner_url("#{method}/#{id}", params))
24
- end
25
- else
26
- self.send(:define_method, method) do
27
- get_paged(partner_url(method))
28
- end
29
- end
30
- end
31
-
32
10
  # @see https://developer.sophos.com/docs/partner-v1/1/routes/tenants/get
33
11
  Helper::def_api_call :tenants, Helper::partner_url(:tenants), true
34
12
 
@@ -61,11 +39,6 @@ module Sophos
61
39
  get_paged(Helper::partner_url("billing/usage/#{year}/#{month}"), params)
62
40
  end
63
41
 
64
- private
65
-
66
- def __partner_url(method, id = nil)
67
- "/partner/v1/#{method}"
68
- end
69
42
  end
70
43
  end
71
44
  end
@@ -1,4 +1,6 @@
1
1
  require 'wrapi'
2
+ require File.expand_path('version', __dir__)
3
+ require File.expand_path('pagination', __dir__)
2
4
 
3
5
  module Sophos
4
6
  # Defines constants and methods related to configuration
@@ -11,10 +13,35 @@ module Sophos
11
13
  # @private
12
14
  attr_accessor *VALID_OPTIONS_KEYS
13
15
 
16
+ DEFAULT_ENDPOINT = 'https://api.central.sophos.com'.freeze
17
+ DEFAULT_ID_ENDPOINT = 'https://id.sophos.com'.freeze
18
+ DEFAULT_UA = "Sophos Ruby API wrapper #{Sophos::VERSION}".freeze
19
+ DEFAULT_PAGINATION = Sophos::RequestPagination::PagesPagination
20
+ DEFAULT_PAGE_SIZE = 100
21
+
22
+ # When this module is extended, set all configuration options to their default values
23
+ def self.extended(base)
24
+ base.reset
25
+ end
26
+
27
+ # Create a hash of options and their values
28
+ def options
29
+ VALID_OPTIONS_KEYS.inject({}) do |option, key|
30
+ option.merge!(key => send(key))
31
+ end
32
+ end
33
+
14
34
  # Reset all configuration options to defaults
15
35
  def reset
16
36
  super
17
37
  self.partner_id = nil
38
+ self.tenant_id = nil
39
+
40
+ self.endpoint = DEFAULT_ENDPOINT
41
+ self.id_endpoint = DEFAULT_ID_ENDPOINT
42
+ self.user_agent = DEFAULT_UA
43
+ self.page_size = DEFAULT_PAGE_SIZE
44
+ self.pagination_class = DEFAULT_PAGINATION
18
45
  end
19
46
  end
20
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sophos
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -1,37 +1,14 @@
1
1
  require "wrapi"
2
2
  require File.expand_path('sophos/api', __dir__)
3
3
  require File.expand_path('sophos/client', __dir__)
4
- require File.expand_path('sophos/pagination', __dir__)
5
- require File.expand_path('sophos/version', __dir__)
6
4
 
7
5
  module Sophos
8
6
  extend Configuration
9
7
  extend WrAPI::RespondTo
10
8
 
11
- DEFAULT_ENDPOINT = 'https://api.central.sophos.com'.freeze
12
- DEFAULT_ID_ENDPOINT = 'https://id.sophos.com'.freeze
13
- DEFAULT_UA = "Sophos Ruby API wrapper #{Sophos::VERSION}".freeze
14
- DEFAULT_PAGINATION = Sophos::RequestPagination::PagesPagination
15
- DEFAULT_PAGE_SIZE = 100
16
-
17
9
  #
18
10
  # @return [Sophos::Client]
19
11
  def self.client(options = {})
20
- Sophos::Client.new({
21
- endpoint: DEFAULT_ENDPOINT,
22
- id_endpoint: DEFAULT_ID_ENDPOINT,
23
- user_agent: DEFAULT_UA,
24
- page_size: DEFAULT_PAGE_SIZE,
25
- pagination_class: DEFAULT_PAGINATION
26
- }.merge(options))
27
- end
28
-
29
- def self.reset
30
- super
31
- self.endpoint = DEFAULT_ENDPOINT
32
- self.id_endpoint = DEFAULT_ID_ENDPOINT
33
- self.user_agent = DEFAULT_UA
34
- self.page_size = DEFAULT_PAGE_SIZE
35
- self.pagination_class = DEFAULT_PAGINATION
12
+ Sophos::Client.new
36
13
  end
37
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sophos_central_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janco Tanis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-14 00:00:00.000000000 Z
11
+ date: 2024-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday