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

이 기사가 도움이 되었습니까?

Listing Service Accounts

All service accounts in the account are listed or a specific service account is listed. Each service account has a unique identifier.

Request

The GET API lists all the service accounts or a specific service account.

GET /service-accounts

Parameters

Name

In

Type

Required

Description

name

query

string

false

This is an optional parameter. Use the parameter to query for a single service account by name.

Code samples

Go

    package main

    import (
        "net/http"
        "io/ioutil"
        "fmt"
    )

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

        req, err := http.NewRequest("GET", "https://api.lyvecloud.seagate.com/v2/service-accounts/", nil)
        if err != nil {
            // handle error
        }

        req.Header = headers

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

        // Read response
        defer resp.Body.Close()
        body, _ := ioutil.ReadAll(resp.Body)

        fmt.Println(string(body)) }

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) throws Exception {
            URL url = new URL("https://api.lyvecloud.seagate.com/v2/service-accounts/");
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setRequestMethod("GET");

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

            // 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 headers = {
        'Accept': 'application/json',
        'Authorization': 'Bearer {access-token}'
    };
    fetch('https://api.lyvecloud.seagate.com/v2/service-accounts/', {
            method: 'GET',
            headers: headers
        })
        .then(function(res) {
            return res.json();
        }).then(function(body) { console.log(body); });

Python

    import requests
    headers = {
        'Accept': 'application/json',
        'Authorization': 'Bearer {access-token}'
    }
    r = requests.get('https://api.lyvecloud.seagate.com/v2/service-accounts/', headers = headers) print(r.json())

Ruby

    require 'rest-client'
    require 'json'

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

    result = RestClient.get 'https://api.lyvecloud.seagate.com/v2/service-accounts/', params: {}, headers: headers

    puts JSON.parse(result)
  

Responses

Status Code Description Schema
200 OK

The operation is successful.
[ 
 { 
   "name": "string", 
   "id": "string", 
   "enabled": true, 
   "readyState": true, 
   "description": "string" 
 }
]
Field Description
name Name of the service account.
id ID of a service account.
enabled State of the Service Account. It can be enabled or disabled.
readyState True if the service account is ready across all regions.
description Description of the service account.
400 Bad request

The token is either invalid 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 The service account was not found.
{
  "code": "string",
  "message": "string"
}
code message
ServiceAccountNotFound Service account was not found.
500 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.