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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
def test_hostname_for_refs_no_resource(self): uri = utils.hostname_for_refs() self.assertEqual("{0}/{1}".format(self.host, self.version), uri)
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)
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)
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))
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))
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))
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)