Module: OpenStack::Identity::ConnectionV2
- Defined in:
- lib/openstack/identity/connection_v2.rb
Instance Method Summary collapse
- #add_user_to_tenant(options) ⇒ Object
-
#create_tenant(options) ⇒ Object
create_tenant(name: ‘tenant1’, description: ‘description’, enabled: true).
-
#create_user(options) ⇒ Object
create_user(name: ‘user1’, password: ‘password1’, email: ‘[email protected]’).
- #delete_tenant(id) ⇒ Object
- #find_tenant_by_name(name) ⇒ Object
- #list_roles ⇒ Object (also: #roles)
- #list_tenants ⇒ Object (also: #tenants)
-
#update_user(user_id, options) ⇒ Object
update_user(1, ‘user1’, password: ‘password1’, email: ‘[email protected]’).
Instance Method Details
#add_user_to_tenant(options) ⇒ Object
44 45 46 47 48 |
# File 'lib/openstack/identity/connection_v2.rb', line 44 def add_user_to_tenant() req_body = JSON.generate('role' => { 'tenantId' => [:tenant_id], 'roleId' => [:role_id] }) @connection.req('POST', "/users/#{[:user_id]}/roleRefs", data: req_body) true end |
#create_tenant(options) ⇒ Object
create_tenant(name: ‘tenant1’, description: ‘description’, enabled: true)
13 14 15 16 17 |
# File 'lib/openstack/identity/connection_v2.rb', line 13 def create_tenant() req_body = JSON.generate('tenant' => ) response = @connection.req('POST', '/tenants', data: req_body) OpenStack::Identity::Tenant.new(JSON.parse(response.body)['tenant']) end |
#create_user(options) ⇒ Object
create_user(name: ‘user1’, password: ‘password1’, email: ‘[email protected]’)
31 32 33 34 35 |
# File 'lib/openstack/identity/connection_v2.rb', line 31 def create_user() req_body = JSON.generate('user' => ) response = @connection.req('POST', '/users', data: req_body) OpenStack::Identity::User.new(JSON.parse(response.body)['user']) end |
#delete_tenant(id) ⇒ Object
24 25 26 27 |
# File 'lib/openstack/identity/connection_v2.rb', line 24 def delete_tenant(id) @connection.req('DELETE', "/tenants/#{id}") true end |
#find_tenant_by_name(name) ⇒ Object
19 20 21 22 |
# File 'lib/openstack/identity/connection_v2.rb', line 19 def find_tenant_by_name(name) response = @connection.req('GET', "/tenants?name=#{name}") OpenStack::Identity::Tenant.new(JSON.parse(response.body)['tenant']) end |
#list_roles ⇒ Object Also known as: roles
50 51 52 53 |
# File 'lib/openstack/identity/connection_v2.rb', line 50 def list_roles response = @connection.req('GET', '/OS-KSADM/roles') OpenStack.symbolize_keys(JSON.parse(response.body)['roles']) end |
#list_tenants ⇒ Object Also known as: tenants
4 5 6 7 8 |
# File 'lib/openstack/identity/connection_v2.rb', line 4 def list_tenants response = @connection.req('GET', '/tenants') tenants_hash = JSON.parse(response.body)['tenants'] tenants_hash.map { |res| OpenStack::Identity::Tenant.new(res) } end |
#update_user(user_id, options) ⇒ Object
update_user(1, ‘user1’, password: ‘password1’, email: ‘[email protected]’)
38 39 40 41 42 |
# File 'lib/openstack/identity/connection_v2.rb', line 38 def update_user(user_id, ) req_body = JSON.generate('user' => ) response = @connection.req('PUT', "/users/#{user_id}", data: req_body) OpenStack::Identity::User.new(JSON.parse(response.body)['user']) end |