Exemplo n.º 1
0
def convert_resource_id_to_href(resource_slug, resource_id):
    """Convert the resource ID to a HATEOAS-style href with resource slug."""
    if resource_id:
        resource = '{slug}/{id}'.format(slug=resource_slug, id=resource_id)
    else:
        resource = '{slug}/????'.format(slug=resource_slug)
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 2
0
def convert_transport_key_to_href(keystone_id, transport_key_id):
    """Convert the transport key IDs to a HATEOS-style href."""
    if transport_key_id:
        resource = 'transport_keys/' + transport_key_id
    else:
        resource = 'transport_keys/????'
    return utils.hostname_for_refs(keystone_id=keystone_id, resource=resource)
Exemplo n.º 3
0
def convert_order_to_href(order_id):
    """Convert the order IDs to a HATEOS-style href."""
    if order_id:
        resource = 'orders/' + order_id
    else:
        resource = 'orders/????'
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 4
0
def convert_container_to_href(container_id):
    """Convert the container IDs to a HATEOS-style href."""
    if container_id:
        resource = 'containers/' + container_id
    else:
        resource = 'containers/????'
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 5
0
def convert_secret_to_href(secret_id):
    """Convert the secret IDs to a HATEOS-style href."""
    if secret_id:
        resource = 'secrets/' + secret_id
    else:
        resource = 'secrets/????'
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 6
0
def convert_list_to_href(resources_name, keystone_id, offset, limit):
    """
    Convert the tenant ID and offset/limit info to a HATEOS-style href
    suitable for use in a list navigation paging interface.
    """
    resource = '{0}?limit={1}&offset={2}'.format(resources_name, limit, offset)
    return utils.hostname_for_refs(keystone_id=keystone_id, resource=resource)
Exemplo n.º 7
0
def convert_order_to_href(keystone_id, order_id):
    """Convert the tenant/order IDs to a HATEOS-style href"""
    if order_id:
        resource = 'orders/' + order_id
    else:
        resource = 'orders/????'
    return utils.hostname_for_refs(keystone_id=keystone_id, resource=resource)
Exemplo n.º 8
0
def convert_order_to_href(keystone_id, order_id):
    """Convert the tenant/order IDs to a HATEOS-style href."""
    if order_id:
        resource = 'orders/' + order_id
    else:
        resource = 'orders/????'
    return utils.hostname_for_refs(keystone_id=keystone_id, resource=resource)
Exemplo n.º 9
0
def convert_container_to_href(keystone_id, container_id):
    """Convert the tenant/container IDs to a HATEOS-style href."""
    if container_id:
        resource = 'containers/' + container_id
    else:
        resource = 'containers/????'
    return utils.hostname_for_refs(keystone_id=keystone_id, resource=resource)
Exemplo n.º 10
0
def convert_secret_to_href(keystone_id, secret_id):
    """Convert the tenant/secret IDs to a HATEOS-style href."""
    if secret_id:
        resource = 'secrets/' + secret_id
    else:
        resource = 'secrets/????'
    return utils.hostname_for_refs(keystone_id=keystone_id, resource=resource)
Exemplo n.º 11
0
def convert_resource_id_to_href(resource_slug, resource_id):
    """Convert the resouce ID to a HATEOAS-style href with resource slug."""
    if resource_id:
        resource = '{slug}/{id}'.format(slug=resource_slug, id=resource_id)
    else:
        resource = '{slug}/????'.format(slug=resource_slug)
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 12
0
def convert_transport_key_to_href(transport_key_id):
    """Convert the transport key IDs to a HATEOS-style href."""
    if transport_key_id:
        resource = 'transport_keys/' + transport_key_id
    else:
        resource = 'transport_keys/????'
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 13
0
def convert_verification_to_href(keystone_id, verification_id):
    """Convert the tenant/verification IDs to a HATEOS-style href."""
    if verification_id:
        resource = 'verifications/' + verification_id
    else:
        resource = 'verifications/????'
    return utils.hostname_for_refs(keystone_id=keystone_id, resource=resource)
Exemplo n.º 14
0
def convert_secret_to_href(keystone_id, secret_id):
    """Convert the tenant/secret IDs to a HATEOS-style href."""
    if secret_id:
        resource = 'secrets/' + secret_id
    else:
        resource = 'secrets/????'
    return utils.hostname_for_refs(keystone_id=keystone_id, resource=resource)
Exemplo n.º 15
0
def convert_verification_to_href(keystone_id, verification_id):
    """Convert the tenant/verification IDs to a HATEOS-style href."""
    if verification_id:
        resource = 'verifications/' + verification_id
    else:
        resource = 'verifications/????'
    return utils.hostname_for_refs(keystone_id=keystone_id, resource=resource)
Exemplo n.º 16
0
def convert_container_to_href(container_id):
    """Convert the container IDs to a HATEOS-style href."""
    if container_id:
        resource = 'containers/' + container_id
    else:
        resource = 'containers/????'
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 17
0
def convert_order_to_href(order_id):
    """Convert the order IDs to a HATEOS-style href."""
    if order_id:
        resource = 'orders/' + order_id
    else:
        resource = 'orders/????'
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 18
0
def convert_secret_to_href(secret_id):
    """Convert the secret IDs to a HATEOS-style href."""
    if secret_id:
        resource = 'secrets/' + secret_id
    else:
        resource = 'secrets/????'
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 19
0
def convert_list_to_href(resources_name, keystone_id, offset, limit):
    """
    Convert the tenant ID and offset/limit info to a HATEOS-style href
    suitable for use in a list navigation paging interface.
    """
    resource = '{0}?limit={1}&offset={2}'.format(resources_name, limit,
                                                 offset)
    return utils.hostname_for_refs(keystone_id=keystone_id, resource=resource)
Exemplo n.º 20
0
def convert_list_to_href(resources_name, offset, limit):
    """Supports pretty output of paged-list hrefs.

    Convert the offset/limit info to a HATEOS-style href
    suitable for use in a list navigation paging interface.
    """
    resource = "{0}?limit={1}&offset={2}".format(resources_name, limit, offset)
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 21
0
def convert_list_to_href(resources_name, offset, limit):
    """Supports pretty output of paged-list hrefs.

    Convert the offset/limit info to a HATEOAS-style href
    suitable for use in a list navigation paging interface.
    """
    resource = '{0}?limit={1}&offset={2}'.format(resources_name, limit, offset)
    return utils.hostname_for_refs(resource=resource)
Exemplo n.º 22
0
 def test_hostname_for_refs_no_resource(self):
     uri = utils.hostname_for_refs()
     self.assertEqual("{0}/{1}".format(self.host, self.version), uri)
Exemplo n.º 23
0
 def test_hostname_for_refs(self):
     uri = utils.hostname_for_refs(resource=self.resource)
     self.assertEqual("{0}/{1}/{2}".format(self.host, self.version,
                                           self.resource), uri)
Exemplo n.º 24
0
 def test_blank_conf_hosthref_for_refs(self):
     utils.CONF.set_override('host_href', '', enforce_type=True)
     uri = utils.hostname_for_refs(resource=self.resource)
     self.assertEqual("{0}/{1}/{2}".format(self.host, self.version,
                                           self.resource), uri)
Exemplo n.º 25
0
 def test_hostname_for_refs_no_keystone_id(self):
     uri = utils.hostname_for_refs(resource=self.resource)
     self.assertEqual(uri, "{0}/{1}".format(self.host, self.version))
Exemplo n.º 26
0
 def test_hostname_for_refs_no_resource(self):
     uri = utils.hostname_for_refs(keystone_id=self.keystone_id)
     self.assertEqual(uri, "{0}/{1}/{2}".format(self.host,
                                                self.version,
                                                self.keystone_id))
Exemplo n.º 27
0
 def test_hostname_for_refs_with_resource_and_keystone_id(self):
     uri = utils.hostname_for_refs(keystone_id=self.keystone_id,
                                   resource=self.resource)
     self.assertEqual(uri, "{0}/{1}/{2}/{3}".format(self.host, self.version,
                                                    self.keystone_id,
                                                    self.resource))
Exemplo n.º 28
0
 def test_blank_conf_hosthref_for_refs(self):
     utils.CONF.set_override('host_href', '')
     uri = utils.hostname_for_refs(resource=self.resource)
     self.assertEqual(
         "{0}/{1}/{2}".format(self.host, self.version, self.resource), uri)