Class: Fog::Identity::OpenStack::V3::Real

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/fog/openstack/identity_v3.rb,
lib/fog/openstack/requests/identity_v3/get_role.rb,
lib/fog/openstack/requests/identity_v3/get_user.rb,
lib/fog/openstack/requests/identity_v3/get_group.rb,
lib/fog/openstack/requests/identity_v3/get_domain.rb,
lib/fog/openstack/requests/identity_v3/get_policy.rb,
lib/fog/openstack/requests/identity_v3/list_roles.rb,
lib/fog/openstack/requests/identity_v3/list_users.rb,
lib/fog/openstack/requests/identity_v3/create_role.rb,
lib/fog/openstack/requests/identity_v3/create_user.rb,
lib/fog/openstack/requests/identity_v3/delete_role.rb,
lib/fog/openstack/requests/identity_v3/delete_user.rb,
lib/fog/openstack/requests/identity_v3/get_project.rb,
lib/fog/openstack/requests/identity_v3/get_service.rb,
lib/fog/openstack/requests/identity_v3/list_groups.rb,
lib/fog/openstack/requests/identity_v3/token_check.rb,
lib/fog/openstack/requests/identity_v3/update_role.rb,
lib/fog/openstack/requests/identity_v3/update_user.rb,
lib/fog/openstack/requests/identity_v3/auth_domains.rb,
lib/fog/openstack/requests/identity_v3/create_group.rb,
lib/fog/openstack/requests/identity_v3/delete_group.rb,
lib/fog/openstack/requests/identity_v3/get_endpoint.rb,
lib/fog/openstack/requests/identity_v3/list_domains.rb,
lib/fog/openstack/requests/identity_v3/token_revoke.rb,
lib/fog/openstack/requests/identity_v3/update_group.rb,
lib/fog/openstack/requests/identity_v3/auth_projects.rb,
lib/fog/openstack/requests/identity_v3/create_domain.rb,
lib/fog/openstack/requests/identity_v3/create_policy.rb,
lib/fog/openstack/requests/identity_v3/delete_domain.rb,
lib/fog/openstack/requests/identity_v3/delete_policy.rb,
lib/fog/openstack/requests/identity_v3/list_policies.rb,
lib/fog/openstack/requests/identity_v3/list_projects.rb,
lib/fog/openstack/requests/identity_v3/list_services.rb,
lib/fog/openstack/requests/identity_v3/update_domain.rb,
lib/fog/openstack/requests/identity_v3/update_policy.rb,
lib/fog/openstack/requests/identity_v3/create_project.rb,
lib/fog/openstack/requests/identity_v3/create_service.rb,
lib/fog/openstack/requests/identity_v3/delete_project.rb,
lib/fog/openstack/requests/identity_v3/delete_service.rb,
lib/fog/openstack/requests/identity_v3/list_endpoints.rb,
lib/fog/openstack/requests/identity_v3/token_validate.rb,
lib/fog/openstack/requests/identity_v3/update_project.rb,
lib/fog/openstack/requests/identity_v3/update_service.rb,
lib/fog/openstack/requests/identity_v3/create_endpoint.rb,
lib/fog/openstack/requests/identity_v3/delete_endpoint.rb,
lib/fog/openstack/requests/identity_v3/update_endpoint.rb,
lib/fog/openstack/requests/identity_v3/group_user_check.rb,
lib/fog/openstack/requests/identity_v3/list_group_users.rb,
lib/fog/openstack/requests/identity_v3/list_user_groups.rb,
lib/fog/openstack/requests/identity_v3/add_user_to_group.rb,
lib/fog/openstack/requests/identity_v3/get_os_credential.rb,
lib/fog/openstack/requests/identity_v3/list_user_projects.rb,
lib/fog/openstack/requests/identity_v3/token_authenticate.rb,
lib/fog/openstack/requests/identity_v3/list_os_credentials.rb,
lib/fog/openstack/requests/identity_v3/create_os_credential.rb,
lib/fog/openstack/requests/identity_v3/delete_os_credential.rb,
lib/fog/openstack/requests/identity_v3/update_os_credential.rb,
lib/fog/openstack/requests/identity_v3/list_role_assignments.rb,
lib/fog/openstack/requests/identity_v3/check_domain_user_role.rb,
lib/fog/openstack/requests/identity_v3/grant_domain_user_role.rb,
lib/fog/openstack/requests/identity_v3/list_domain_user_roles.rb,
lib/fog/openstack/requests/identity_v3/remove_user_from_group.rb,
lib/fog/openstack/requests/identity_v3/check_domain_group_role.rb,
lib/fog/openstack/requests/identity_v3/check_project_user_role.rb,
lib/fog/openstack/requests/identity_v3/grant_domain_group_role.rb,
lib/fog/openstack/requests/identity_v3/grant_project_user_role.rb,
lib/fog/openstack/requests/identity_v3/list_domain_group_roles.rb,
lib/fog/openstack/requests/identity_v3/list_project_user_roles.rb,
lib/fog/openstack/requests/identity_v3/revoke_domain_user_role.rb,
lib/fog/openstack/requests/identity_v3/check_project_group_role.rb,
lib/fog/openstack/requests/identity_v3/grant_project_group_role.rb,
lib/fog/openstack/requests/identity_v3/list_project_group_roles.rb,
lib/fog/openstack/requests/identity_v3/revoke_domain_group_role.rb,
lib/fog/openstack/requests/identity_v3/revoke_project_user_role.rb,
lib/fog/openstack/requests/identity_v3/revoke_project_group_role.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#authenticate

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/fog/openstack/identity_v3.rb', line 156

def initialize(options={})
  @openstack_auth_token = options[:openstack_auth_token]

  @openstack_region = options[:openstack_region]

  unless @openstack_auth_token
    missing_credentials = Array.new
    @openstack_api_key = options[:openstack_api_key]
    @openstack_username = options[:openstack_username]
    @openstack_userid = options[:openstack_userid]

    missing_credentials << :openstack_api_key unless @openstack_api_key
    unless @openstack_username || @openstack_userid
      missing_credentials << 'openstack_username or openstack_userid'
    end
    raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
  end


  @openstack_tenant = options[:openstack_tenant]
  @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
  @openstack_management_url = options[:openstack_management_url]
  @openstack_must_reauthenticate = false
  @openstack_service_type = options[:openstack_service_type] || ['identity_v3','identityv3','identity']
  @openstack_service_name = options[:openstack_service_name]

  @connection_options = options[:connection_options] || {}

  @openstack_current_user_id = options[:openstack_current_user_id]

  @openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'

  @current_user = options[:current_user]
  @current_tenant = options[:current_tenant]

  authenticate

  @persistent = options[:persistent] || false
  @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the value of attribute auth_token.



152
153
154
# File 'lib/fog/openstack/identity_v3.rb', line 152

def auth_token
  @auth_token
end

#current_tenantObject (readonly)

Returns the value of attribute current_tenant.



150
151
152
# File 'lib/fog/openstack/identity_v3.rb', line 150

def current_tenant
  @current_tenant
end

#current_userObject (readonly)

Returns the value of attribute current_user.



149
150
151
# File 'lib/fog/openstack/identity_v3.rb', line 149

def current_user
  @current_user
end

#unscoped_tokenObject (readonly)

Returns the value of attribute unscoped_token.



151
152
153
# File 'lib/fog/openstack/identity_v3.rb', line 151

def unscoped_token
  @unscoped_token
end

Instance Method Details

#add_user_to_group(group_id, user_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/add_user_to_group.rb', line 6

def add_user_to_group(group_id, user_id)
  request(
      :expects => [204],
      :method => 'PUT',
      :path => "groups/#{group_id}/users/#{user_id}"
  )
end

#auth_domains(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/openstack/requests/identity_v3/auth_domains.rb', line 7

def auth_domains(options={})
  params = Hash.new
  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  request(
      :expects => [200],
      :method => 'GET',
      :path => "auth/domains",
      :query => params
  )
end

#auth_projects(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/openstack/requests/identity_v3/auth_projects.rb', line 6

def auth_projects(options={})
  params = Hash.new
  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  request(
      :expects => [200],
      :method => 'GET',
      :path => "auth/projects",
      :query => params
  )

end

#check_domain_group_role(id, group_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/check_domain_group_role.rb', line 6

def check_domain_group_role(id, group_id, role_id)
  request(
      :expects => [204],
      :method => 'HEAD',
      :path => "domains/#{id}/groups/#{group_id}/roles/#{role_id}"
  )
end

#check_domain_user_role(id, user_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/check_domain_user_role.rb', line 6

def check_domain_user_role(id, user_id, role_id)
  request(
      :expects => [204],
      :method => 'HEAD',
      :path => "domains/#{id}/users/#{user_id}/roles/#{role_id}"
  )
end

#check_project_group_role(id, group_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/check_project_group_role.rb', line 6

def check_project_group_role(id, group_id, role_id)
  request(
      :expects => [204],
      :method => 'HEAD',
      :path => "projects/#{id}/groups/#{group_id}/roles/#{role_id}"
  )
end

#check_project_user_role(id, user_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/check_project_user_role.rb', line 6

def check_project_user_role(id, user_id, role_id)
  request(
      :expects => [204],
      :method => 'HEAD',
      :path => "projects/#{id}/users/#{user_id}/roles/#{role_id}"
  )
end

#create_domain(domain) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/create_domain.rb', line 6

def create_domain(domain)
  request(
      :expects => [201],
      :method => 'POST',
      :path => "domains",
      :body => Fog::JSON.encode(:domain => domain)
  )
end

#create_endpoint(endpoint) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/create_endpoint.rb', line 6

def create_endpoint(endpoint)
  request(
      :expects => [201],
      :method => 'POST',
      :path => "endpoints",
      :body => Fog::JSON.encode(:endpoint => endpoint)
  )
end

#create_group(group) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/create_group.rb', line 6

def create_group(group)
  request(
      :expects => [201],
      :method => 'POST',
      :path => "groups",
      :body => Fog::JSON.encode(:group => group)
  )
end

#create_os_credential(credential) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/create_os_credential.rb', line 6

def create_os_credential(credential)
  request(
      :expects => [201],
      :method => 'POST',
      :path => "credentials",
      :body => Fog::JSON.encode(:credential => credential)
  )
end

#create_policy(policy) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/create_policy.rb', line 6

def create_policy(policy)
  request(
      :expects => [201],
      :method => 'POST',
      :path => "policies",
      :body => Fog::JSON.encode(:policy => policy)
  )
end

#create_project(project) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/create_project.rb', line 6

def create_project(project)
  request(
      :expects => [201],
      :method => 'POST',
      :path => "projects",
      :body => Fog::JSON.encode(:project => project)
  )
end

#create_role(role) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/create_role.rb', line 6

def create_role(role)
  request(
      :expects => [201],
      :method => 'POST',
      :path => "roles",
      :body => Fog::JSON.encode(:role => role)
  )
end

#create_service(service) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/create_service.rb', line 6

def create_service(service)
  request(
      :expects => [201],
      :method => 'POST',
      :path => "services",
      :body => Fog::JSON.encode(:service => service)
  )
end

#create_user(user) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/create_user.rb', line 6

def create_user(user)
  request(
      :expects => [201],
      :method => 'POST',
      :path => "users",
      :body => Fog::JSON.encode(:user => user)
  )
end

#credentialsObject



197
198
199
200
201
202
203
204
205
# File 'lib/fog/openstack/identity_v3.rb', line 197

def credentials
  {:provider => 'openstack',
   :openstack_auth_url => @openstack_auth_uri.to_s,
   :openstack_auth_token => @auth_token,
   :openstack_management_url => @openstack_management_url,
   :openstack_current_user_id => @openstack_current_user_id,
   :current_user => @current_user,
   :current_tenant => @current_tenant}
end

#delete_domain(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/delete_domain.rb', line 6

def delete_domain(id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "domains/#{id}"
  )
end

#delete_endpoint(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/delete_endpoint.rb', line 6

def delete_endpoint(id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "endpoints/#{id}"
  )
end

#delete_group(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/delete_group.rb', line 6

def delete_group(id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "groups/#{id}"
  )
end

#delete_os_credential(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/delete_os_credential.rb', line 6

def delete_os_credential(id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "credentials/#{id}"
  )
end

#delete_policy(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/delete_policy.rb', line 6

def delete_policy(id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "policies/#{id}"
  )
end

#delete_project(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/delete_project.rb', line 6

def delete_project(id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "projects/#{id}"
  )
end

#delete_role(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/delete_role.rb', line 6

def delete_role(id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "roles/#{id}"
  )
end

#delete_service(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/delete_service.rb', line 6

def delete_service(id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "services/#{id}"
  )
end

#delete_user(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/delete_user.rb', line 6

def delete_user(id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "users/#{id}"
  )
end

#get_domain(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/get_domain.rb', line 6

def get_domain(id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "domains/#{id}"
  )
end

#get_endpoint(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/get_endpoint.rb', line 6

def get_endpoint(id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "endpoints/#{id}"
  )
end

#get_group(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/get_group.rb', line 6

def get_group(id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "groups/#{id}"
  )
end

#get_os_credential(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/get_os_credential.rb', line 6

def get_os_credential(id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "credentials/#{id}"
  )
end

#get_policy(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/get_policy.rb', line 6

def get_policy(id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "policies/#{id}"
  )
end

#get_project(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/get_project.rb', line 6

def get_project(id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "projects/#{id}"
  )
end

#get_role(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/get_role.rb', line 6

def get_role(id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "roles/#{id}"
  )
end

#get_service(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/get_service.rb', line 6

def get_service(id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "projects/#{id}"
  )
end

#get_user(id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/get_user.rb', line 6

def get_user(id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "users/#{id}"
  )
end

#grant_domain_group_role(id, group_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/grant_domain_group_role.rb', line 6

def grant_domain_group_role(id, group_id, role_id)
  request(
      :expects => [204],
      :method => 'PUT',
      :path => "domains/#{id}/groups/#{group_id}/roles/#{role_id}"
  )
end

#grant_domain_user_role(id, user_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/grant_domain_user_role.rb', line 6

def grant_domain_user_role(id, user_id, role_id)
  request(
      :expects => [204],
      :method => 'PUT',
      :path => "domains/#{id}/users/#{user_id}/roles/#{role_id}"
  )
end

#grant_project_group_role(id, group_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/grant_project_group_role.rb', line 6

def grant_project_group_role(id, group_id, role_id)
  request(
      :expects => [204],
      :method => 'PUT',
      :path => "projects/#{id}/groups/#{group_id}/roles/#{role_id}"
  )
end

#grant_project_user_role(id, user_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/grant_project_user_role.rb', line 6

def grant_project_user_role(id, user_id, role_id)
  request(
      :expects => [204],
      :method => 'PUT',
      :path => "projects/#{id}/users/#{user_id}/roles/#{role_id}"
  )
end

#group_user_check(group_id, user_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/group_user_check.rb', line 6

def group_user_check(group_id, user_id)
  request(
      :expects => [204],
      :method => 'HEAD',
      :path => "groups/#{group_id}/users/#{user_id}"
  )
end

#list_domain_group_roles(id, group_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/list_domain_group_roles.rb', line 6

def list_domain_group_roles(id, group_id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "domains/#{id}/groups/#{group_id}/roles"
  )
end

#list_domain_user_roles(id, user_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/list_domain_user_roles.rb', line 6

def list_domain_user_roles(id, user_id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "domains/#{id}/users/#{user_id}/roles"
  )
end

#list_domains(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/openstack/requests/identity_v3/list_domains.rb', line 6

def list_domains(options={})
  params = Hash.new
  params['name'] = options[:name] if options[:name]
  params['enabled'] = options[:enabled] if options[:enabled]

  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  request(
      :expects => [200],
      :method => 'GET',
      :path => "domains",
      :query => params
  )
end

#list_endpoints(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/openstack/requests/identity_v3/list_endpoints.rb', line 6

def list_endpoints(options={})
  params = Hash.new
  params['service_id'] = options[:service_id] if options[:service_id]
  params['interface'] = options[:interface] if options[:interface]

  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  request(
      :expects => [200],
      :method => 'GET',
      :path => "endpoints",
      :query => params
  )
end

#list_group_users(id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/openstack/requests/identity_v3/list_group_users.rb', line 6

def list_group_users(id, options={})
  params = Hash.new
  params['name'] = options[:name] if options[:name]
  params['domain_id'] = options[:domain_id] if options[:domain_id]
  params['description'] = options[:description] if options[:description]

  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  request(
      :expects => [200],
      :method => 'GET',
      :path => "groups/#{id}/users",
      :query => params
  )
end

#list_groups(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/openstack/requests/identity_v3/list_groups.rb', line 6

def list_groups(options={})
  params = Hash.new
  params['user_id'] = options[:user_id] if options[:user_id]
  params['domain_id'] = options[:domain_id] if options[:domain_id]
  params['name'] = options[:name] if options[:name]
  params['enabled'] = options[:enabled] if options[:enabled]

  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  if params['user_id'] then
    request(
        :expects => [200],
        :method => 'GET',
        :path => "users/#{params['user_id']}groups",
        :query => params
    )
  else
    request(
        :expects => [200],
        :method => 'GET',
        :path => "groups",
        :query => params
    )
  end
end

#list_os_credentials(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/openstack/requests/identity_v3/list_os_credentials.rb', line 6

def list_os_credentials(options={})
  params = Hash.new
  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)
  params['name'] = options[:name] if options[:name]

  request(
      :expects => [200],
      :method => 'GET',
      :path => "credentials",
      :query => params
  )
end

#list_policies(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/openstack/requests/identity_v3/list_policies.rb', line 6

def list_policies(options={})
  params = Hash.new
  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  request(
      :expects => [200],
      :method => 'GET',
      :path => "policies",
      :query => params
  )
end

#list_project_group_roles(id, group_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/list_project_group_roles.rb', line 6

def list_project_group_roles(id, group_id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "projects/#{id}/groups/#{group_id}/roles"
  )
end

#list_project_user_roles(id, user_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/list_project_user_roles.rb', line 6

def list_project_user_roles(id, user_id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "projects/#{id}/users/#{user_id}/roles"
  )
end

#list_projects(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/openstack/requests/identity_v3/list_projects.rb', line 6

def list_projects(options={})
  params = Hash.new
  params['user_id'] = options[:user_id] if options[:user_id]
  params['domain_id'] = options[:domain_id] if options[:domain_id]
  params['name'] = options[:name] if options[:name]
  params['enabled'] = options[:enabled] if options[:enabled]

  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  if params['user_id'] then
    request(
        :expects => [200],
        :method => 'GET',
        :path => "users/#{params['user_id']}/projects",
        :query => params
    )
  else
    request(
        :expects => [200],
        :method => 'GET',
        :path => "projects",
        :query => params
    )
  end
end

#list_role_assignments(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/openstack/requests/identity_v3/list_role_assignments.rb', line 6

def list_role_assignments(options={})
  params = Hash.new
  params['group.id'] = options[:group_id] if options[:group_id]
  params['role.id'] = options[:role_id] if options[:role_id]
  params['scope.domain.id'] = options[:domain_id] if options[:domain_id]
  params['scope.project.id'] = options[:project_id] if options[:project_id]
  params['user.id'] = options[:user_id] if options[:user_id]
  params['effective'] = options[:effective] if options[:effective]

  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  request(
      :expects => [200],
      :method => 'GET',
      :path => "role_assignments",
      :query => params
  )
end

#list_roles(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/openstack/requests/identity_v3/list_roles.rb', line 6

def list_roles(options={})
  params = Hash.new
  params['name'] = options[:name] if options[:name]

  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

#          if params['user_id'] then
# Returns 404 "The resource could not be found."
# https://bugs.launchpad.net/keystone/+bug/933565 reports this - bug is set to "Won't fix"
#   user_id = params.delete 'user_id'
#   request(
#       :expects => [200],
#       :method  => 'GET',
#       :path    => "users/#{user_id}/roles",
#       :query   => params
#   )
# else
  request(
      :expects => [200],
      :method => 'GET',
      :path => "roles",
      :query => params
  )
#          end
end

#list_services(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/openstack/requests/identity_v3/list_services.rb', line 6

def list_services(options={})
  params = Hash.new
  params['type'] = options[:type] if options[:type]

  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  request(
      :expects => [200],
      :method => 'GET',
      :path => "services",
      :query => params
  )
end

#list_user_groups(user_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/list_user_groups.rb', line 6

def list_user_groups(user_id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "users/#{user_id}/groups"
  )
end

#list_user_projects(user_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/list_user_projects.rb', line 6

def list_user_projects(user_id)
  request(
      :expects => [200],
      :method => 'GET',
      :path => "users/#{user_id}/projects"
  )
end

#list_users(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/openstack/requests/identity_v3/list_users.rb', line 6

def list_users(options={})
  params = Hash.new
  params['domain_id'] = options[:domain_id] if options[:domain_id]
  params['name'] = options[:name] if options[:name]
  params['enabled'] = options[:enabled] if options[:enabled]

  params['page'] = options.fetch(:page, 1)
  params['per_page'] = options.fetch(:per_page, 30)

  request(
      :expects => [200],
      :method => 'GET',
      :path => "users",
      :query => params
  )
end

#reloadObject



207
208
209
# File 'lib/fog/openstack/identity_v3.rb', line 207

def reload
  @connection.reset
end

#remove_user_from_group(group_id, user_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/remove_user_from_group.rb', line 6

def remove_user_from_group(group_id, user_id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "groups/#{group_id}/users/#{user_id}"
  )
end

#request(params) ⇒ Object



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/fog/openstack/identity_v3.rb', line 211

def request(params)
  retried = false
  begin
    response = @connection.request(params.merge({
                                                    :headers => {
                                                        'Content-Type' => 'application/json',
                                                        'Accept' => 'application/json',
                                                        'X-Auth-Token' => @auth_token
                                                    }.merge!(params[:headers] || {}),
                                                    :path => "#{@path}/#{params[:path]}" #,
                                                }))
  rescue Excon::Errors::Unauthorized => error
    raise if retried
    retried = true

    @openstack_must_reauthenticate = true
    authenticate
    retry
  rescue Excon::Errors::HTTPStatusError => error
    raise case error
            when Excon::Errors::NotFound
              Fog::Identity::OpenStack::NotFound.slurp(error)
            else
              error
          end
  end
  unless response.body.empty?
    response.body = Fog::JSON.decode(response.body)
  end
  response
end

#revoke_domain_group_role(id, group_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/revoke_domain_group_role.rb', line 6

def revoke_domain_group_role(id, group_id, role_id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "domains/#{id}/groups/#{group_id}/roles/#{role_id}"
  )
end

#revoke_domain_user_role(id, user_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/revoke_domain_user_role.rb', line 6

def revoke_domain_user_role(id, user_id, role_id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "domains/#{id}/users/#{user_id}/roles/#{role_id}"
  )
end

#revoke_project_group_role(id, group_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/revoke_project_group_role.rb', line 6

def revoke_project_group_role(id, group_id, role_id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "projects/#{id}/groups/#{group_id}/roles/#{role_id}"
  )
end

#revoke_project_user_role(id, user_id, role_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/requests/identity_v3/revoke_project_user_role.rb', line 6

def revoke_project_user_role(id, user_id, role_id)
  request(
      :expects => [204],
      :method => 'DELETE',
      :path => "projects/#{id}/users/#{user_id}/roles/#{role_id}"
  )
end

#token_authenticate(auth) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/token_authenticate.rb', line 6

def token_authenticate(auth)
  request(
      :expects => [201],
      :method => 'POST',
      :path => "auth/tokens",
      :body => Fog::JSON.encode(auth)
  )
end

#token_check(subject_token) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/token_check.rb', line 6

def token_check(subject_token)
  request(
      :expects => [200, 204],
      :method => 'HEAD',
      :path => "auth/tokens",
      :headers => {"X-Subject-Token" => subject_token, "X-Auth-Token" => auth_token, }
  )
end

#token_revoke(subject_token) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/token_revoke.rb', line 6

def token_revoke(subject_token)
  request(
      :expects => [200, 204],
      :method => 'DELETE',
      :path => "auth/tokens",
      :headers => {"X-Subject-Token" => subject_token, "X-Auth-Token" => auth_token, }
  )
end

#token_validate(subject_token) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/openstack/requests/identity_v3/token_validate.rb', line 6

def token_validate(subject_token)

  request(
      :expects => [200],
      :method => 'GET',
      :path => "auth/tokens",
      :headers => {"X-Subject-Token" => subject_token, "X-Auth-Token" => auth_token}
  )
end

#update_domain(id, domain) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/update_domain.rb', line 6

def update_domain(id, domain)
  request(
      :expects => [200],
      :method => 'PATCH',
      :path => "domains/#{id}",
      :body => Fog::JSON.encode(:domain => domain)
  )
end

#update_endpoint(id, endpoint) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/update_endpoint.rb', line 6

def update_endpoint(id, endpoint)
  request(
      :expects => [200],
      :method => 'PATCH',
      :path => "endpoints/#{id}",
      :body => Fog::JSON.encode(:endpoint => endpoint)
  )
end

#update_group(id, group) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/update_group.rb', line 6

def update_group(id, group)
  request(
      :expects => [200],
      :method => 'PATCH',
      :path => "groups/#{id}",
      :body => Fog::JSON.encode(:group => group)
  )
end

#update_os_credential(id, credential) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/update_os_credential.rb', line 6

def update_os_credential(id, credential)
  request(
      :expects => [200],
      :method => 'PATCH',
      :path => "credentials/#{id}",
      :body => Fog::JSON.encode(:credential => credential)
  )
end

#update_policy(id, policy) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/update_policy.rb', line 6

def update_policy(id, policy)
  request(
      :expects => [200],
      :method => 'PATCH',
      :path => "policies/#{id}",
      :body => Fog::JSON.encode(:policy => policy)
  )
end

#update_project(id, project) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/update_project.rb', line 6

def update_project(id, project)
  request(
      :expects => [200],
      :method => 'PATCH',
      :path => "projects/#{id}",
      :body => Fog::JSON.encode(:project => project)
  )
end

#update_role(id, role) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/update_role.rb', line 6

def update_role(id, role)
  request(
      :expects => [200],
      :method => 'PATCH',
      :path => "roles/#{id}",
      :body => Fog::JSON.encode(:role => role)
  )
end

#update_service(id, service) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/update_service.rb', line 6

def update_service(id, service)
  request(
      :expects => [200],
      :method => 'PATCH',
      :path => "services/#{id}",
      :body => Fog::JSON.encode(:service => service)
  )
end

#update_user(id, user) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/requests/identity_v3/update_user.rb', line 6

def update_user(id, user)
  request(
      :expects => [200],
      :method => 'PATCH',
      :path => "users/#{id}",
      :body => Fog::JSON.encode(:user => user)
  )
end