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

Was this content helpful?

Listing Permissions

All the permissions created for the account are listed.

Request

The GET /permissions/ allows listing all the permissions of the account. Optionally, you can specify the name to get the specific permission in the account.

GET /permissions

Parameters

Name In Type Required Description
name query string false This is an optional parameter. Query the name parameter for single permission.

Code samples

Go

    package main

    import (
        "net/http"
    )

    func main() {
        headers := map[string][]string{
            "Accept": []string{
                "application/json",
            },
            "Authorization": []string{
                "Bearer {access-token}",
            },
        }

        req, err := http.NewRequest("GET", "https://api.lyvecloud.seagate.com/v2/permissions/", nil)
        if err != nil {
            // handle error
        }
        req.Header = headers

        client := &http.Client{}
        resp, err := client.Do(req)
        if err != nil {
            // handle error
        }
        // handle response _ = resp }

Java

    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;

    public class Main {
        public static void main(String[] args) {
            try {
                URL obj = new URL("https://api.lyvecloud.seagate.com/v2/permissions/");
                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/permissions/', {
        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/permissions/', headers=headers)
        r.raise_for_status()  # Raises a HTTPError if the response status is 4xx, 5xx
        print(r.json())
    except requests.exceptions.RequestException as err:
        print ("There was a problem with the request:", 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/permissions/', headers: headers
        p JSON.parse(result)
    rescue RestClient::ExceptionWithResponse => e
        e.response
    end
  

Responses

Status Code Description Return JSON payload
200 OK

Successfully returned permission list.
[
 { 
   "name": "string",
   "id": "string",
   "description": "string", 
   "type": "all-buckets",
   "readyState": true,
   "createTime": "2019-08-24T14:15:22Z"
  }
 ]
Field Description
name The permission name.
id The permission id.
description Description of the permission.
type The values for the permission type can be:

  • all-buckets: The permission is applied to all the existing and new buckets in the account.

    When you select the type as all-buckets , the parameters prefix, buckets and policy are not part of the request.

  • bucket-prefix: Specify a string of characters at the beginning of the name of the bucket as a prefix to apply for permission.

    When you select the type as bucket-prefix, the parameters buckets and policy are not part of the request.

  • bucket-names: The permission is applied to the specified buckets names.

    When you select the type as bucket-names, the parameters prefix and policy are not part of the request.

  • policy: Permission is applied based on the policy permission file. For more information, see Managing bucket access permissions.

    When you select the type as policy, the parameters actions, prefix, and buckets are not part of the request.
readyState State of permissions.True if the permission is ready across all regions.
createTime Time of the permission creation.
400 Bad request

Either the token is invalid or expired.
{
  "code": "string",
  "message": "string"
}
code message
ExpiredToken Token expired.
InvalidToken Token is not valid.
404 Not Found

The permission is no longer available.
{
  "code": "string",
  "message": "string"
}
code message
PermissionNotFound Permission was not found.
403 Forbidden

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