GUARDAR COMO PDF
Lyve Cloud Account API version 2 Guide
Lyve Cloud Account API version 2 

¿Le pareció útil este contenido?

Updating a Permission

You can update all the permission parameters, bucket permission, and their associated actions.

Request

Performing a PUT operation on specific a permission updates the permission.

PUT /permissions/{permissionId}

Body parameter

{ 
  "name": "string", 
  "description": "string", 
  "type": "bucket-names", 
  "actions": "all-operations", 
  "prefix": "string", 
  "buckets": [ "string" ], 
  "policy": {}
}

Parameters

NameInTypeRequiredDescription
permissionIdpathstringtrueNumeric ID of the permission to update.
namebodystringtrueName of the permission.
descriptionbodystringtrueDescription of the permission.
typebodystringtrue
The values for the permission type can be:

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

    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 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: Using the Policy permission, you can allow or deny requests at a granular level based on the elements in the policy, resources, and conditions of the request.

    When you select the type as policy, the parameters actions, prefix, and buckets are not part of the request.
actionsbodystringfalseThe values for the actions can be:

  • all-operations: Allows you to perform all the operations.
  • read-only: Allows you to perform a read only operation on one or more selected buckets and their objects.
  • write-only: Allows you to write objects into the selected buckets without reading them back.
These values are applied to the permission type.
prefixbodystringfalsePrefix of your bucket names to assign and apply the permission based on the permission type bucket-prefix.
bucketsbodystringfalseSpecify one or more bucket names based on permission type bucket-names.
policybodyobjectfalseThe policy file is based on permission type policy.For more information, see Managing bucket access permissions.

Code samples

Go

    package main

    import (
        "bytes"
        "net/http"
    )

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

        jsonReq := "{json request body}" // replace with your JSON request body
        data := bytes.NewBuffer([]byte(jsonReq))

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

        req.Header = headers

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

        // handle response }

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/permissions/{PermissionId}");
                HttpURLConnection con = (HttpURLConnection) obj.openConnection();
                con.setRequestMethod("POST");

                // Set request headers
                con.setRequestProperty("Content-Type", "application/json");
                con.setRequestProperty("Accept", "application/json");
                con.setRequestProperty("Authorization", "Bearer {access-token}");

                int responseCode = con.getResponseCode();
                System.out.println("Response Code : " + responseCode);

                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 inputBody = '{ "name": "string", "description": "string", "type": "all-buckets", "actions": "all-operations", "prefix": "string", "buckets": [ "string" ], "policy": {} }';
    const headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'Authorization': 'Bearer {access-token}'
    };

    fetch('https://api.lyvecloud.seagate.com/v2/permissions/{PermissionId}', {
        method: 'POST',
        body: inputBody,
        headers: headers
    })
    .then(response => {
        if (!response.ok) {
            throw new Error('Network response was not ok');
        }
        return response.json(); }) .then(body => { console.log(body); }) .catch(error => { console.error('There has been a problem with your fetch operation:', error); });

Python

    import requests

    headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'Authorization': 'Bearer {access-token}'
    }

    data = '{ "name": "string", "description": "string", "type": "all-buckets", "actions": "all-operations", "prefix": "string", "buckets": [ "string" ], "policy": {} }'  # replace with your actual data

    try:
        r = requests.post('https://api.lyvecloud.seagate.com/v2/permissions/{PermissionId}', headers=headers, data=data)
        r.raise_for_status()  # Raises a HTTPError if the response status is 4xx, 5xx
    except requests.exceptions.RequestException as err:
        print(f"An error occurred: {err}")
    else: print(r.json())

Ruby

    require 'rest-client'
    require 'json'

    headers = {
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
        'Authorization' => 'Bearer {access-token}'
    }

    result = RestClient.post(
        'https://api.lyvecloud.seagate.com/v2/permissions/{PermissionId}',
        {}.to_json,  # Convert params to JSON
        headers
    )

    puts JSON.parse(result)  # Use 'puts' instead of 'p' for printing
  

Responses

StatusDescriptionReturn JSON Payload
200OK

The update operation is successful.
Successfully updated the permission.
400Bad Request

It is an invalid request or invalid permission information.
{
  "code": "string",
  "message": "string"
}
codemessage
ExpiredTokenToken expired.
InvalidTokenToken is not valid.
InvalidArgumentThis error might occur for the following reasons:
  • One or more of the specified arguments was not valid.
  • The request was missing an argument.
403Forbidden

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

The permission to be updated is no longer available.
{
  "code": "string",
  "message": "string"
}
codemessage
PermissionNotFoundPermission was not found.
409The permission name already exists

The permission is not ready for update operation and is being processed by some regions.
{
  "code": "string",
  "message": "string"
}
codemessage
PermissionNameAlreadyExistsThe permission name is already in use. Please use a different name.
PermissionNotReadyPermission is still being processed by some regions.
500Locked

The 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.