def __fetch_all_endpoint_service_global_level(self):
     kvendpoints = {}
     resp = self.request(IAMURL % (self.domain, "endpoints"), "GET",
                         endpoint_filter=identity_service.AdminService())
     endpoints = resp.json().get("endpoints", [])
     resp = self.request(IAMURL % (self.domain, "services"), "GET",
                         endpoint_filter=identity_service.AdminService())
     services = resp.json().get("services", [])
     id_endpoint_map, servicetype_id_map = {}, {}
     lzip = itertools.izip_longest if hasattr(itertools, "izip_longest") else itertools.zip_longest
     for endpoint, service in lzip(endpoints, services):
         if endpoint and endpoint.get("enabled") and endpoint.get("region") is None:
             id_endpoint_map[endpoint.get("service_id")] = endpoint.get("url")
         if service and service.get("enabled"):
             servicetype_id_map.setdefault(service.get("type"), [])
             servicetype_id_map[service.get("type")].append(service.get("id"))
     for k, v in servicetype_id_map.items():
         for serviceid in v:
             url = id_endpoint_map.get(serviceid)
             if url != "":
                 kvendpoints[k] = url
                 break
             if kvendpoints.get(k, ""):
                 break
     return kvendpoints
Esempio n. 2
0
 def __fetch_all_endpoint_service(self):
     kvendpoints = {}
     resp = self.request(IAMURL % (self.region, self.domain, "endpoints"), "GET",
                         endpoint_filter=identity_service.AdminService())
     endpoints = resp.json().get("endpoints", [])
     resp = self.request(IAMURL % (self.region, self.domain, "services"), "GET",
                         endpoint_filter=identity_service.AdminService())
     services = resp.json().get("services", [])
     id_endpoint_map, servicetype_id_map = {}, {}
     lzip = itertools.izip_longest if hasattr(itertools, "izip_longest")  else itertools.zip_longest
     for endpoint, service in lzip(endpoints, services):
         if endpoint and endpoint.get("enabled"):
             id_endpoint_map.setdefault(endpoint.get("service_id"), [])
             data_map = {endpoint.get("region"): endpoint.get("url")}
             id_endpoint_map[endpoint.get("service_id")].append(data_map)
         if service and service.get("enabled"):
             servicetype_id_map.setdefault(service.get("type"), [])
             servicetype_id_map[service.get("type")].append(service.get("id"))
     for k, v in servicetype_id_map.items():
         for serviceid in v:
             for region_url_map in id_endpoint_map.get(serviceid, []):
                 url = region_url_map.get(self.region, "")
                 if url != "":
                     kvendpoints[k] = url.replace("$(tenant_id)s", self.project_id)
                     break
             if kvendpoints.get(k, ""):
                 break
     return kvendpoints
Esempio n. 3
0
class Tenant(resource.Resource):
    resource_key = 'tenant'
    resources_key = 'tenants'
    base_path = '/tenants'
    service = identity_service.AdminService()

    # capabilities
    allow_create = True
    allow_retrieve = True
    allow_update = True
    allow_delete = True
    allow_list = True

    # Properties
    description = resource.prop('description')
    enabled = resource.prop('enabled', type=bool)
    name = resource.prop('name')
Esempio n. 4
0
class User(resource.Resource):
    resource_key = 'user'
    resources_key = 'users'
    base_path = '/users'
    service = identity_service.AdminService()

    # capabilities
    allow_create = True
    allow_retrieve = True
    allow_update = True
    allow_delete = True
    allow_list = True

    # Properties
    email = resource.prop('email')
    enabled = resource.prop('enabled', type=bool)
    name = resource.prop('name')
Esempio n. 5
0
class User(resource.Resource):
    resource_key = 'user'
    resources_key = 'users'
    base_path = '/users'
    service = identity_service.AdminService()

    # capabilities
    allow_create = True
    allow_get = True
    allow_update = True
    allow_delete = True
    allow_list = True

    # Properties
    #: The email of this user. *Type: string*
    email = resource.Body('email')
    #: Setting this value to ``False`` prevents the user from authenticating or
    #: receiving authorization. Additionally, all pre-existing tokens held by
    #: the user are immediately invalidated. Re-enabling a user does not
    #: re-enable pre-existing tokens. *Type: bool*
    is_enabled = resource.Body('enabled', type=bool)
    #: The name of this user. *Type: string*
    name = resource.Body('name')
class Tenant(resource.Resource):
    resource_key = 'tenant'
    resources_key = 'tenants'
    base_path = '/tenants'
    service = identity_service.AdminService()

    # capabilities
    allow_create = True
    allow_retrieve = True
    allow_update = True
    allow_delete = True
    allow_list = True

    # Properties
    #: The description of the tenant. *Type: string*
    description = resource.prop('description')
    #: Setting this attribute to ``False`` prevents users from authorizing
    #: against this tenant. Additionally, all pre-existing tokens authorized
    #: for the tenant are immediately invalidated. Re-enabling a tenant
    #: does not re-enable pre-existing tokens. *Type: bool*
    enabled = resource.prop('enabled', type=bool)
    #: Unique tenant name. *Type: string*
    name = resource.prop('name')
Esempio n. 7
0
 def test_admin_service(self):
     sot = identity_service.AdminService()
     self.assertEqual('identity', sot.service_type)
     self.assertEqual('admin', sot.interface)
     self.assertIsNone(sot.region)
     self.assertIsNone(sot.service_name)