Class: Puppet::Util::NetworkDevice::Auth0_tenant::Device
- Inherits:
-
Simple::Device
- Object
- Simple::Device
- Puppet::Util::NetworkDevice::Auth0_tenant::Device
- Extended by:
- Forwardable
- Defined in:
- lib/puppet/util/network_device/auth0_tenant/device.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #facts ⇒ Object
-
#initialize(*args) ⇒ Device
constructor
A new instance of Device.
- #patch_resource_server(id, options) ⇒ Object
-
#resource_servers(page: nil, per_page: nil) ⇒ Object
(also: #get_resource_servers)
These methods are missing from the Auth0 gem for some reason, a PR is in progress but in the meantime we'll just stick it here.
Constructor Details
#initialize(*args) ⇒ Device
Returns a new instance of Device.
12 13 14 15 16 17 18 19 20 |
# File 'lib/puppet/util/network_device/auth0_tenant/device.rb', line 12 def initialize(*args) super @connection = Auth0::Client.new( client_id: config['client_id'], client_secret: config['client_secret'], domain: config['domain'], api_version: 2, ) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
11 12 13 |
# File 'lib/puppet/util/network_device/auth0_tenant/device.rb', line 11 def connection @connection end |
Instance Method Details
#facts ⇒ Object
22 23 24 25 26 27 |
# File 'lib/puppet/util/network_device/auth0_tenant/device.rb', line 22 def facts { tenant_domain: config['domain'], management_client_id: config['client_id'], } end |
#patch_resource_server(id, options) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/puppet/util/network_device/auth0_tenant/device.rb', line 40 def patch_resource_server(id, ) raise Auth0::MissingClientId, 'Must specify a resource server id' if id.to_s.empty? raise Auth0::MissingParameter, 'Must specify a valid body' if .to_s.empty? path = "#{@connection.send(:resource_servers_path)}/#{id}" @connection.patch(path, ) end |
#resource_servers(page: nil, per_page: nil) ⇒ Object Also known as: get_resource_servers
These methods are missing from the Auth0 gem for some reason, a PR is in progress but in the meantime we'll just stick it here.
31 32 33 34 35 36 37 |
# File 'lib/puppet/util/network_device/auth0_tenant/device.rb', line 31 def resource_servers(page: nil, per_page: nil) request_params = { page: !page.nil? ? page.to_i : nil, per_page: !page.nil? && !per_page.nil? ? per_page.to_i : nil } @connection.get(@connection.send(:resource_servers_path), request_params) end |