Class: DistributedPress::V1::Client::Admin
- Inherits:
-
Object
- Object
- DistributedPress::V1::Client::Admin
- Defined in:
- lib/distributed_press/v1/client/admin.rb
Overview
Admins can create and remove publishers
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create(schema) ⇒ DistributedPress::V1::Schemas::Admin
Creates a Admin, requires a token with admin capabilities.
-
#delete(schema) ⇒ Boolean
Deletes a Admin, requires a token with admin capabilities.
-
#initialize(client) ⇒ Admin
constructor
A new instance of Admin.
Constructor Details
#initialize(client) ⇒ Admin
Returns a new instance of Admin.
13 14 15 |
# File 'lib/distributed_press/v1/client/admin.rb', line 13 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/distributed_press/v1/client/admin.rb', line 10 def client @client end |
Instance Method Details
#create(schema) ⇒ DistributedPress::V1::Schemas::Admin
Creates a Admin, requires a token with admin capabilities
21 22 23 24 25 26 |
# File 'lib/distributed_press/v1/client/admin.rb', line 21 def create(schema) validate_schema! schema validate_capabilities! Schemas::Admin.new.call(**client.post(endpoint: '/v1/admin', schema: schema)) end |
#delete(schema) ⇒ Boolean
Deletes a Admin, requires a token with admin capabilities
32 33 34 35 36 37 |
# File 'lib/distributed_press/v1/client/admin.rb', line 32 def delete(schema) validate_schema! schema validate_capabilities! client.delete(endpoint: "/v1/admin/#{schema[:id]}") end |