Class: DistributedPress::V1::Client::Admin

Inherits:
Object
  • Object
show all
Defined in:
lib/distributed_press/v1/client/admin.rb

Overview

Admins can create and remove publishers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Admin

Returns a new instance of Admin.

Parameters:



13
14
15
# File 'lib/distributed_press/v1/client/admin.rb', line 13

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (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

Parameters:

Returns:

  • (Boolean)


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