SAVE AS PDF
Lyve Cloud Account API version 2 Guide
Lyve Cloud Account API version 2 

Was this content helpful?

Usage

This API is used to get historical storage usage of the account for the current month or specified time range.

Getting historical storage usage by month

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.

 Note
  • Based on the time range, it returns zero (0) if the data is unavailable.
  • The data is displayed for a maximum interval of six months.

Request

The GET operation provides the account's monthly usage for a specified duration.

GET /usage/monthly

Parameters

NameInTypeRequiredDescription
fromMonthqueryIntegertrueSpecifies the start month, inclusive, from which to retrieve usage data.

Where, zero corresponds to January and 11 corresponds to December.
fromYearqueryIntegertrueSpecifies the start year, inclusive, from which to retrieve usage data.
toMonthqueryIntegertrueSpecifies the end month, inclusive, from which to retrieve usage data.

Where, zero corresponds to January and 11 corresponds to December.
toYearqueryIntegertrueSpecifies the end year, inclusive, from which to retrieve usage data.

Code samples

Go

    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) // ... }

Java

    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(); }

JavaScript

    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); });

Python

    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())

Ruby

    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)
  

Responses

Status CodeDescriptionReturned JSON Payload
200OK

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"
                }
            ]
        }
    ]
}
FieldDescription
yearUsage of the account for selected year.
monthUsage of the account for selected month.
nameName of the bucket.
usageGBBucket consumption in GB.
totalUsageGBTotal storage consumption in GB.
bucketsBucket consumption.
subAccountsDetails of sub-account.
subAccountNameName of the sub-account.
subAccountIdUnique identifier of a sub-account.
400Bad Request
{
  "code": "string",
  "message": "string"
}
codemessage
TokenExpiredToken expired.
InvalidTokenToken is not valid.
InvalidTimeRangeInvalid time range.
403Forbidden

The account has no services enabled.
{
  "code": "string",
  "message": "string"
}
codemessage
NoServiceAvailableThe account has no services enabled for it.
500The server encountered an internal error.
{
  "code": "string",
  "message": "string"
}
codemessage
InternalerrorThe server encountered an internal error. Please retry the request.
503Service Unavailable
{
  "code": "string",
  "message": "string"
}
codemessage
ServiceNotReadyThe server is not ready to handle the request. Please retry the request later.

Getting current month storage usage

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.

 Note—Based on the time range, it returns zero (0) if the data is unavailable.

Request

The GET operation provides usage for the current month to date.

GET /usage/current

Code samples

Go

    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) // ... }

Java

    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(); } } }

JavaScript

    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); });

Python

    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}")

Ruby

    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
  

Responses

Status CodeDescriptionReturned JSON payload
200OK

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, usageBySubAccountis 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"
            }
        ]
    }
}
FieldDescription
numBucketsNumber of buckets.
totalUsageGBTotal storage consumption in GB.
bucketsBucket consumption.
nameBucket name.
usageGBBucket consumption in GB
totalUsageGBTotal usage of the master account, including the sub-accounts.
subAccountsDetails of sub-account.
subAccountNameName of the sub-account.
subAccountIdUnique identifier of a sub-account.
usageGBUsage of the account in GB.
usersLists the total number of users for each sub-account.
serviceAccountsLists the number of service accounts for each sub-account.
bucketsTotal number of buckets created in the Sub-account.
trialRemaining number of days for the trial to expire. If the trial is not provisioned for the account, then the trial is -1.
createTimeDate and time when the Sub-account is created.
400The token is not valid or is expired.
{
  "code": "string",
  "message": "string"
}
codemessage
ExpiredTokenToken expired.
InvalidTokenToken is not valid.
403Forbidden

The account has no services enabled.
{
  "code": "string",
  "message": "string"
}
codemessage
NoServiceAvailableThe account has no services enabled for it.
500The server encountered an internal error.
{
  "code": "string",
  "message": "string"
}
codemessage
InternalErrorThe server encountered an internal error. Please retry the request.
503Service Unavailable
{
  "code": "string",
  "message": "string"
}
codemessage
ServiceNotReadyThe server is not ready to handle the request. Please retry the request later.