Lyve Cloud Account API version 2 Guide
Lyve Cloud Account API version 2 

このコンテンツは役に立ちましたか?

Getting Permission by ID

Permission ID is a unique identifier for a permission.

Request

Performing a GET operation on specific permission retrieves the permission.

GET /permissions/{permissionId}

Parameters

Name In Type Required Description
permissionId path string true Numeric ID of the 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/{PermissionId}", 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/{PermissionId}");
                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/{PermissionId}', {
        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/{PermissionId}', 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}'
    }

    result = RestClient.get 'https://api.lyvecloud.seagate.com/v2/permissions/{PermissionId}', params: {}, headers: headers

    puts JSON.parse(result)
  

Responses

Status Code Description Return JSON Payload
200 OK

Specified Permission ID is found, and the details are returned in the response.
{ 
  "id": "string",
   "name": "string",
   "description": "string",
   "type": "all-buckets",
   "readyState": true,
   "actions": "all-operations",
   "prefix": "string",
   "buckets": [ "string" ],
   "policy": {}
}

Note—If the type is policy, then the fields actions, prefix, and buckets will not display.

Field Description
id ID of the permission.
name Name of the permission.
description Description of the permission.
type The values for the permission type can be:

  • all-operations: Allows to perform all the operations.

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

  • bucket-prefix: Specify a string of characters at the beginning of the bucket's name 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: Permission is applied to the specified bucket 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 Using policy permission files.

    When you select the type as policy, the parameters actions, prefix, and buckets are not part of the request.
readyState State of the permissions. True if the permission is ready across all regions.
actions The values for the actions can be:

  • all-operations: Allows you to perform all operations.
  • read-only: Allows you to perform a read only operation on one or more selected buckets and their objects.
  • write-only: This allows you to write objects into the selected buckets without reading them back.
prefix Specify a prefix of your bucket names to assign and apply the permission based on the permission type bucket-prefix.
buckets Specify one or more bucket names based on permission type.
policy The policy file based on permission type policy.
400 Either the token is not valid or expired.
{
  "code": "string",
  "message": "string"
}
code message
ExpiredToken Token expired.
InvalidToken Token is not valid.
403 Forbidden

The account has no services enabled.
{
  "code": "string",
  "message": "string"
}
code message
NoServiceAvailable The account has no services enabled for it.
404 Not Found

The permission is not available.
{
  "code": "string",
  "message": "string"
}
code message
PermissionNotFound The permission was not found.
500 An internal error has occurred.
{
  "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.