Hash :
c08634a8
Author :
Date :
2016-05-14T12:48:12
1 2 3 4 5 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
defmodule ExOvh.Ovh.V1.Webstorage.Query do
@moduledoc ~s"""
Helper functions for building `queries directed at the `/cdn/webstorage` part of the custom ovh api.
## Functions Summary
| Function | Description | OVH API call |
|---|---|---|
| `get_services/0` | <small>Get a list of all webstorage cdn services.</small> | <sub><sup>GET /v1/cdn/webstorage</sup></sub> |
| `get_service/1` | <small>Get the domain, server and storage limits for a specific webstorage cdn service</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}</sup></sub> |
| `get_service_info/1` | <small>Get a administrative details for a specific webstorage cdn service</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}/serviceInfos</sup></sub> |
| `get_service_stats/2` | <small>Get statistics for a specific webstorage cdn service</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}/statistics</sup></sub> |
| `get_credentials/1` | <small>Get credentials for using the swift compliant api</small> | <sub><sup>GET /v1/cdn/webstorage/{serviceName}/statistics</sup></sub> |
## Example
ExOvh.Ovh.V1.Webstorage.Query.get_all_webstorage() |> ExOvh.Ovh.request()
"""
alias ExOvh.Ovh.Query
@doc ~s"""
Get a list of all webstorage cdn services available for the client account
## Api call
GET /v1/cdn/webstorage
## Example
ExOvh.Ovh.V1.Webstorage.Query. get_services() |> ExOvh.Ovh.request()
"""
@spec get_services() :: Query.t
def get_services() do
%Query{
method: :get,
uri: "/cdn/webstorage",
params: :nil
}
end
@doc ~s"""
Get the domain, server and storage limits for a specific webstorage cdn service
## Api call
GET /v1/cdn/webstorage/{serviceName}
## Arguments
- `service_name`: Name of the Webstorage CDN service - assigned by OVH.
## Example
alias ExOvh.Ovh.V1.Webstorage.Query
service_name = "cdnwebstorage-????"
query = Query.get_service(service_name)
{:ok, resp} = ExOvh.Ovh.request(query)
%{
"domain" => domain,
"storageLimit => storage_limit,
"server" => server
} = resp.body
"""
@spec get_service(String.t) :: Query.t
def get_service(service_name) do
%Query{
method: :get,
uri: "/cdn/webstorage/",
params: service_name
}
end
@doc ~s"""
Get a administrative details for a specific webstorage cdn service
## Api call
GET /v1/cdn/webstorage/{serviceName}/serviceInfos
## Arguments
- `service_name`: Name of the Webstorage CDN service - assigned by OVH.
## Example
alias ExOvh.Ovh.V1.Webstorage.Query
service_name = "cdnwebstorage-????"
Query.get_service_info(service_name)
{:ok, resp} = ExOvh.Ovh.request(query)
"""
@spec get_service_info(String.t) :: Query.t
def get_service_info(service_name) do
%Query{
method: :get,
uri: "/cdn/webstorage/#{service_name}/serviceInfos",
params: :nil
}
end
@doc ~s"""
Get statistics for a specific webstorage cdn service
## Api call
GET /v1/cdn/webstorage/{serviceName}/statistics
## Arguments
- `service_name`: Name of the Webstorage CDN service - assigned by OVH.
- `options`:
- `period can be "month", "week" or "day"`
- `type can be "backend", "quota" or "cdn"`
## Example
alias ExOvh.Ovh.V1.Webstorage.Query
service_name = "cdnwebstorage-????"
query = Query.get_service_stats(service_name, [period: "month", type: "backend"])
{:ok, resp} = ExOvh.Ovh.request(query)
"""
@spec get_service_stats(String.t, Keyword.t) :: Query.t
def get_service_stats(service_name, opts \\ []) do
period = Keyword.get(opts, "period", "month")
type = Keyword.get(opts, "type", "cdn")
%Query{
method: :get,
uri: "/cdn/webstorage/#{service_name}/statistics",
params: %{"period" => period, "type" => type}
}
end
@doc ~s"""
Get credentials for using the swift compliant api
## Api call
GET /v1/cdn/webstorage/{serviceName}/credentials
## Arguments
- `service_name`: Name of the Webstorage CDN service - assigned by OVH.
## Example
alias ExOvh.Ovh.V1.Webstorage.Query
service_name = "cdnwebstorage-????"
query = Query.get_webstorage_credentials(service_name)
{:ok, resp} = ExOvh.Ovh.request(query)
"""
@spec get_credentials(String.t) :: ExOvh.Query.Ovh.t
def get_credentials(service_name) do
%Query{
method: :get,
uri: "/cdn/webstorage/#{service_name}/credentials",
params: :nil
}
end
end