另存为 PDF
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

NameInTypeRequiredDescription
permissionIdpathstringtrueNumeric 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 CodeDescriptionReturn JSON Payload
200OK

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.

FieldDescription
idID of the permission.
nameName of the permission.
descriptionDescription of the permission.
typeThe 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.
readyStateState of the permissions. True if the permission is ready across all regions.
actionsThe 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.
prefixSpecify a prefix of your bucket names to assign and apply the permission based on the permission type bucket-prefix.
bucketsSpecify one or more bucket names based on permission type.
policyThe policy file based on permission type policy.
400Either the token is not valid or 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.
404Not Found

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