Heeft deze informatie u geholpen?
Hoe kunnen we dit artikel nog verbeteren?
This API is used to get historical storage usage of the account for the current month or specified time range.
The monthly average usage is calculated by averaging the daily average usage of all the days in that month. The monthly average usage is used to calculate the monthly cost at the end of the month.
The GET operation provides the account's monthly usage for a specified duration.
GET /usage/monthly
Name | In | Type | Required | Description |
---|---|---|---|---|
fromMonth | query | Integer | true | Specifies the start month, inclusive, from which to retrieve usage data. Where, zero corresponds to January and 11 corresponds to December. |
fromYear | query | Integer | true | Specifies the start year, inclusive, from which to retrieve usage data. |
toMonth | query | Integer | true | Specifies the end month, inclusive, from which to retrieve usage data. Where, zero corresponds to January and 11 corresponds to December. |
toYear | query | Integer | true | Specifies the end year, inclusive, from which to retrieve usage data. |
package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{ "application/json", }, "Authorization": []string{ "Bearer {access-token}", }, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://api.lyvecloud.seagate.com/v2/usage/monthly/", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... }
try { URL obj = new URL("https://api.lyvecloud.seagate.com/v2/usage/monthly/?from%2Dmonth=11&from%2Dyear=2020&to%2Dmonth=11&to%2Dyear=2020"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); } catch (IOException e) { e.printStackTrace(); }
const headers = { 'Accept': 'application/json', 'Authorization': 'Bearer {access-token}' }; fetch('https://api.lyvecloud.seagate.com/v2/usage/monthly/?from%2Dmonth=11&from%2Dyear=2020&to%2Dmonth=11&to%2Dyear=2020', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); });
import requests headers = { 'Accept': 'application/json', 'Authorization': 'Bearer {access-token}' } r = requests.get('https://api.lyvecloud.seagate.com/v2/usage/monthly/', params = { 'from-month': '11', 'from-year': '2020', 'to-month': '11', 'to-year': '2020' }, headers = headers) print(r.json())
require 'rest-client' require 'json' headers = { 'Accept' => 'application/json', 'Authorization' => 'Bearer {access-token}' } result = RestClient.get 'https://api.lyvecloud.seagate.com/v2/usage/monthly/', params: { 'from-month' => '[monthNumber](#schemamonthnumber)', 'from-year' => '[yearNumber](#schemayearnumber)', 'to-month' => '[monthNumber](#schemamonthnumber)', 'to-year' => '[yearNumber](#schemayearnumber)' }, headers: headers p JSON.parse(result)
Status Code | Description | Returned JSON Payload | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
200 | OK Successfully returns the data usage. Each item in return corresponds to one month. If the account is a master account, the response includes usageByBucket returning data usage for every bucket in the master account, and it also includes usageBySubAccount , returning data usage for its available sub-accounts.If the account is a sub-account, the response includes usageByBucket , returning data usage for every bucket in the sub-account. However, usageBySubAccount , is not returned, as there are no sub-accounts associated to another sub account. |
{ "usageByBucket": [ { "year": 0, "month": 0, "totalUsageGB": 0, "buckets": [ { "name": "string", "usageGB": 0 } ] } ], "usageBySubAccount": [ { "year": 0, "month": 0, "totalUsageGB": 0, "subAccounts": [ { "subAccountName": "subname1", "subAccountId": "string", "usageGB": 0, "createTime": "2022-10-16T14:02:20.319Z" } ] } ] }
|
||||||||||||||||||||
400 | Bad Request | { "code": "string", "message": "string" }
|
||||||||||||||||||||
403 | Forbidden The account has no services enabled. |
{ "code": "string", "message": "string" }
|
||||||||||||||||||||
500 | The server encountered an internal error. | { "code": "string", "message": "string" }
|
||||||||||||||||||||
503 | Service Unavailable | { "code": "string", "message": "string" }
|
This API returns the current month's storage usage and lists all buckets in the account and their calculated total usage size to the current date. In addition, you get the total number of buckets currently in the account and the total calculated usage.
The GET operation provides usage for the current month to date.
GET /usage/current
package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{ "application/json", }, "Authorization": []string{ "Bearer {access-token}", }, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://api.lyvecloud.seagate.com/v2/usage/current/", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... }
import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static void main(String[] args) { try { URL obj = new URL("https://api.lyvecloud.seagate.com/v2/usage/current/"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); } catch (Exception e) { e.printStackTrace(); } } }
const headers = { 'Accept': 'application/json', 'Authorization': 'Bearer {access-token}' }; fetch('https://api.lyvecloud.seagate.com/v2/usage/current/', { method: 'GET', headers: headers }) .then(function(res) { if (!res.ok) { throw new Error(`HTTP error! status: ${res.status}`); } return res.json(); }) .then(function(body) { console.log(body); }) .catch(function(error) { console.log('There was a problem with the fetch operation: ' + error.message); });
import requests headers = { 'Accept': 'application/json', 'Authorization': 'Bearer {access-token}' } try: r = requests.get('https://api.lyvecloud.seagate.com/v2/usage/current/', headers=headers) r.raise_for_status() print(r.json()) except requests.exceptions.HTTPError as err: print(f"HTTP error occurred: {err}") except Exception as err: print(f"An error occurred: {err}")
require 'rest-client' require 'json' headers = { 'Accept' => 'application/json', 'Authorization' => 'Bearer {access-token}' } begin result = RestClient.get 'https://api.lyvecloud.seagate.com/v2/usage/current/', params: {}, headers: headers p JSON.parse(result) rescue RestClient::ExceptionWithResponse => e puts "An error occurred: #{e.message}" end
Status Code | Description | Returned JSON payload | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
200 | OK Successfully return usage data. If the account is a master account, the response includes usageByBucket , returning data usage for every bucket in the master account, and it also includes usageBySubAccount , returning data usage for its available sub-accounts.If the account is sub-account, the response includes usageByBucket , returning data usage for every bucket in the sub-account. However, usageBySubAccount is not returned, as there are no sub-accounts associated to another sub-account |
{ "usageByBucket": { "numBuckets": 0, "totalUsageGB": 0, "buckets": [ { "name": "string", "usageGB": 0 } ] }, "usageBySubAccount": { "totalUsageGB": 0, "subAccounts": [ { "subAccountName": "subname1", "subAccountId": "string", "usageGB": 0, "users": 0, "serviceAccounts": 0, "buckets": 0, "trial": 0, "createTime": "2022-10-16T14:06:51.494Z" } ] } }
|
||||||||||||||||||||||||||||||||
400 | The token is not valid or is expired. | { "code": "string", "message": "string" }
|
||||||||||||||||||||||||||||||||
403 | Forbidden The account has no services enabled. |
{ "code": "string", "message": "string" }
|
||||||||||||||||||||||||||||||||
500 | The server encountered an internal error. | { "code": "string", "message": "string" }
|
||||||||||||||||||||||||||||||||
503 | Service Unavailable | { "code": "string", "message": "string" }
|