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

Was this content helpful?

Creating a Service Account

Service accounts allow applications to authenticate and access Lyve Cloud buckets and objects. When creating a service account, the access key and secret key are generated. This information must be saved at account creation, as you cannot recover key details afterwards. You must create buckets and assign permission to buckets before creating a service account. For more information, see Administrator's Guide - Bucket Management and Managing bucket access permissions.

 Note—You must have at least one permission before creating a service account.

Request

The POST request creates a service account. The service account generates the credentials holding the access and secret keys.

POST /service-accounts

Body parameter

{ 
  "name": "string", 
  "description": "string", 
  "permissions": [ "string" ]
}

Parameters

Name In Type Required Description
name body string true Name of the new service account.

The name allows only alphanumeric, '-', '_' or space. Maximum length is 128 characters.
description body string false Description of the new service account.
permissions body [string] true Permission ID to apply to the service account.

Code samples

Go

    package main

    import (
        "bytes"
        "net/http"
    )

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

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

        req, err := http.NewRequest("PUT", "https://api.lyvecloud.seagate.com/v2/service-accounts/", data)
        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.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.URL;

    public class Main {
        public static void main(String[] args) throws Exception {
            URL url = new URL("https://api.lyvecloud.seagate.com/v2/service-accounts/");
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setRequestMethod("PUT");

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

            // Enable input and output streams
            con.setDoOutput(true);
            con.setDoInput(true);

            // Write request body
            String jsonInputString = "{}";  // Replace with your JSON request
            try(OutputStream os = con.getOutputStream()) {
                byte[] input = jsonInputString.getBytes("utf-8");
                os.write(input, 0, input.length);
            }

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

            // Read response
            try(BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine = null;
                while ((responseLine = br.readLine()) != null) { response.append(responseLine.trim()); } System.out.println(response.toString()); } } }

JavaScript

    const inputBody = JSON.stringify({
        "name": "string",
        "description": "string",
        "permissions": ["string"]
    });

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

    fetch('https://api.lyvecloud.seagate.com/v2/service-accounts/', {
        method: 'PUT', body: inputBody, headers: headers }) .then(res => res.json()) .then(body => console.log(body));

Python

    import requests

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

    # You should have a payload for a PUT request
    data = {}  # Replace with your actual data

    r = requests.put('https://api.lyvecloud.seagate.com/v2/service-accounts/', headers=headers, json=data) print(r.json())

Ruby

    require 'rest-client'
    require 'json'

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

    # You should have a payload for a PUT request
    params = {}  # Replace with your actual data

    result = RestClient.put(
        'https://api.lyvecloud.seagate.com/v2/service-accounts/',
        params.to_json,  # Convert params to JSON
        headers
    )

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

Responses

Status Code Description Return JSON Payload
200 OK

The request to create a Service Account was successfully sent.

Note—There might be few seconds difference between the time the successful response is received, and when the action is completed, as some regions may still process the create service account request.

If you need to start using the service account immediately, we suggest you wait for a few seconds and perform a retry operation until readyState=True. For more information, see Getting service account data by ID.
{ 
  "id": "string", 
  "accessKey": "string", 
  "secret": "string"
  "expirationDate": "2022-11-15"
}
Field Description
id ID of the service account.
accessKey Access key generated after creating a service account.
secret: Secret key generated after creating a service account.
expirationDate Date when the service account will expire.
400 Bad Request

Invalid service account 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.
409 The service account name already exists. The service account name must be unique.
{
  "code": "string",
  "message": "string"
}
code message
ServiceAccountNameAlreadyExists The service account name is already in use. Please use a different name.
500 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.