ExOvh v0.1.1 ExOvh.Services.V1.Cloud.Cloudstorage.Query

Helper functions for building queries directed at the cloudstorage related parts of the /cloud part of the OVH API.

See ExOvh.Services.V1.Cloud.Query for generic cloud requests.

Functions Summary

Function Description OVH API call
get_containers/1 Get containers for a given swift tenant id (project id or ovh service name) GET /cloud/project/{serviceName}/storage
create_container/3 Create a container for a given tenantid (ovh servicename), a container and a region. POST /cloud/project/{serviceName}/storage
get_access/1 Get access details for the Swift API for a given swift tenantid (ovh servicename) GET /cloud/project/{serviceName}/storage/access
container_info/2 Gets details about a container such as objects, size, region, public or not, static_url, name, ... GET /cloud/project/{serviceName}/storage/{containerId}
delete_container/2 Deletes a given container. DELETE /cloud/project/{serviceName}/storage/{containerId}
modify_container_cors/3 Modify the CORS settings for a container. See swift docs POST /cloud/project/{serviceName}/storage/{containerId}/cors Add CORS support on your container
deploy_container_as_static_website/2 Deploy the container files as a static web site. POST /cloud/project/{serviceName}/storage/{containerId}/static

Notes

  • service_name or serviceName corresponds to the Openstack tenant_id

Example

ExOvh.Services.V1.Cloud.Cloudstorage.Query.get_containers(service_name) |> ExOvh.request!()

Summary

Functions

Gets the details for a given container

Gets the xauthtoken and the swift endpoints for a given tenantid (ovh servicename). A different endpoint is returned depending on the region. Examples of regions include "BHS1", "SBG1", "GRA1". With these details, requests can be made through the Swift api

Get storage containers

Functions

container_info(service_name, container_id)

Specs

container_info(String.t, String.t) :: ExOvh.Query.t

Gets the details for a given container.

Returns information such as a list of objects in the container, size of the container, whether the container is public or not, the region of the container, the name of the container, the number of stored objects for the container and the static url for the container.

Api call

GET /cloud/project/{serviceName}/storage/{containerId}

Arguments

  • service_name: service name for the ovh cloud service
  • container_id: containerid for a given container. Note: this is not the same as the containername.

Example

ExOvh.Services.V1.Cloud.Cloudstorage.Query.container_info(service_name, container_id) |> ExOvh.request!()
create_container(service_name, container_name, region \\ "SBG1")

Specs

create_container(String.t, String.t, String.t) :: ExOvh.Query.t

Create container

Api call

POST /cloud/project/{serviceName}/storage

Arguments

  • service_name: service name for the ovh cloud service
  • container_name: name for the new container
  • region: region for the new container, defaults to "SBG1". See regions by running: Currently can choose from "GRA1", "BHS1", "SBG1".

Example

ExOvh.Services.V1.Cloud.Cloudstorage.Query.create_container(service_name, "test_container") |> ExOvh.request!()
delete_container(service_name, container_id)

Specs

delete_container(String.t, String.t) :: ExOvh.Query.t

Deletes a given container.

Note: containerd is not the same as containername.

Api call

DELETE /cloud/project/{serviceName}/storage/{containerId}

Arguments

  • service_name: service name for the ovh cloud service
  • container_id: containerid for a given container. Note: this is not the same as the containername.

Example

ExOvh.Services.V1.Cloud.Cloudstorage.Query.delete_container(service_name, container_id) |> ExOvh.request!()
deploy_container_as_static_website(service_name, container_id)

Specs

deploy_container_as_static_website(String.t, String.t) :: ExOvh.Query.t

Deploy a container as a static website.

Modifies the ACL settings for a container on the "X-Container-Read" header and also other container metadata. See swift auth docs, swift acl middleware and swift account middleware for more information.

Api call

POST /cloud/project/{serviceName}/storage/{containerId}/static

Arguments

  • service_name: service name for the ovh cloud service
  • container_id: containerid for a given container. Note: this is not the same as the containername.

Example

ExOvh.Services.V1.Cloud.Cloudstorage.Query.modify_container_cors(service_name, container_id, "http://localhost:4001/") |> ExOvh.Ovh.prepare_request() |> ExOvh.request!()

Notes

To get a full overview of the container details with all metadata, the Swift client should be used. To see the changes, try running the following command for the container_name associated with this container_id. In fact, the OVH functions are not really required, most changes can be made directly using queries sent via the Swift.Cloudstorage client.

account = ExOvh.Swift.Cloudstorage.account()
container = "test_container"
Openstex.Swift.V1.Query.container_info(container, account) |> ExOvh.Swift.Cloudstorage.request!() |> Map.get(:headers)
get_access(service_name)

Specs

get_access(String.t) :: ExOvh.Query.t

Gets the xauthtoken and the swift endpoints for a given tenantid (ovh servicename). A different endpoint is returned depending on the region. Examples of regions include "BHS1", "SBG1", "GRA1". With these details, requests can be made through the Swift api.

Api call

GET /cloud/project/{serviceName}/storage/access

Arguments

  • service_name: service name for the ovh cloud service

Example

ExOvh.Services.V1.Cloud.Cloudstorage.Query.get_access(service_name) |> ExOvh.request!()
get_containers(service_name)

Specs

get_containers(String.t) :: ExOvh.Query.t

Get storage containers

Api call

GET /cloud/project/{serviceName}/storage

Arguments

  • service_name: service name for the ovh cloud service

Example

ExOvh.Services.V1.Cloud.Cloudstorage.Query.get_containers(service_name) |> ExOvh.request!()
modify_container_cors(service_name, container_id, origin \\ {})

Specs

modify_container_cors(String.t, String.t, String.t) :: ExOvh.Query.t

Modify CORS settings for a container.

Modifies the container metadata such that cross origin requests can be permitted. See CORS section of swift docs for more info. Ans see here for more on CORS in general

Metadata Use
X-Container-Meta-Access-Control-Allow-Origin Origins to be allowed to make Cross Origin Requests, space separated.

Note: containerd is not the same as containername.

Api call

DELETE /cloud/project/{serviceName}/storage/{containerId}

Arguments

  • service_name: service name for the ovh cloud service
  • container_id: containerid for a given container. Note: this is not the same as the containername.
  • origin: an origin that may make cross origin requests to the container. Defaults to {} (none) if left absent.

Example

ExOvh.Services.V1.Cloud.Cloudstorage.Query.modify_container_cors(service_name, container_id, "http://localhost:4001/") |> ExOvh.Ovh.prepare_request() |> ExOvh.request!()

Notes

To get a full overview of the container details with all metadata, the Swift client should be used. To see the changes, try running the following command for the container_name associated with this container_id. In fact, the OVH functions are not really required, most changes can be made directly using queries sent via the Swift.Cloudstorage client.

account = ExOvh.Swift.Cloudstorage.account()
container = "test_container"
Openstex.Swift.V1.Query.container_info(container, account) |> ExOvh.Swift.Cloudstorage.request!() |> Map.get(:headers) |> Map.get("X-Container-Meta-Access-Control-Allow-Origin")