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

Cet article vous a-t-il été utile ?

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

Name In Type Required Description
permissionId path string true Numeric ID of the permission to update.
name body string true Name of the permission.
description body string true Description of the permission.
type body string true
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.
actions body string false The 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.
prefix body string false Prefix of your bucket names to assign and apply the permission based on the permission type bucket-prefix.
buckets body string false Specify one or more bucket names based on permission type bucket-names.
policy body object false The 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

Status Description Return JSON Payload
200 OK

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

It is an invalid request or invalid permission information.
{
  "code": "string",
  "message": "string"
}
code message
ExpiredToken Token expired.
InvalidToken Token is not valid.
InvalidArgument This error might occur for the following reasons:
  • One or more of the specified arguments was not valid.
  • The request was missing an argument.
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 to be updated is no longer available.
{
  "code": "string",
  "message": "string"
}
code message
PermissionNotFound Permission was not found.
409 The permission name already exists

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

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.