Class: Xapixctl::PhoenixClient::OrganizationConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/xapixctl/phoenix_client/organization_connection.rb

Direct Known Subclasses

ProjectConnection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, org) ⇒ OrganizationConnection

Returns a new instance of OrganizationConnection.



8
9
10
11
12
# File 'lib/xapixctl/phoenix_client/organization_connection.rb', line 8

def initialize(connection, org)
  @connection = connection
  @client = connection.client
  @org = org
end

Instance Attribute Details

#orgObject (readonly)

Returns the value of attribute org.



6
7
8
# File 'lib/xapixctl/phoenix_client/organization_connection.rb', line 6

def org
  @org
end

Instance Method Details

#apply(resource_description, &block) ⇒ Object



26
27
28
29
30
# File 'lib/xapixctl/phoenix_client/organization_connection.rb', line 26

def apply(resource_description, &block)
  result_handler(block).
    prepare_data(->(data) { data['resource_ids'] }).
    run { @client[generic_resource_path].put(resource_description.to_json, content_type: :json) }
end

#delete(resource_type, resource_id, &block) ⇒ Object



32
33
34
35
# File 'lib/xapixctl/phoenix_client/organization_connection.rb', line 32

def delete(resource_type, resource_id, &block)
  result_handler(block).
    run { @client[resource_path(resource_type, resource_id)].delete }
end

#resource(resource_type, resource_id, format: :hash, &block) ⇒ Object



14
15
16
17
18
# File 'lib/xapixctl/phoenix_client/organization_connection.rb', line 14

def resource(resource_type, resource_id, format: :hash, &block)
  result_handler(block).
    formatter(FORMATTERS[format]).
    run { @client[resource_path(resource_type, resource_id)].get }
end

#resource_ids(resource_type, &block) ⇒ Object



20
21
22
23
24
# File 'lib/xapixctl/phoenix_client/organization_connection.rb', line 20

def resource_ids(resource_type, &block)
  result_handler(block).
    prepare_data(->(data) { data['resource_ids'] }).
    run { @client[resources_path(resource_type)].get }
end