Esse conteúdo foi útil?
Como poderíamos tornar este artigo mais útil?
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.
The POST request creates a service account. The service account generates the credentials holding the access and secret keys.
POST /service-accounts
{ "name": "string", "description": "string", "permissions": [ "string" ] }
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. |
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 }
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()); } } }
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));
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())
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
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" }
|
||||||||||
400 | Bad Request Invalid service account information. |
{ "code": "string", "message": "string" }
|
||||||||||
403 | Forbidden The account has no services enabled. |
{ "code": "string", "message": "string" }
|
||||||||||
409 | The service account name already exists. The service account name must be unique. | { "code": "string", "message": "string" }
|
||||||||||
500 | Server encountered an internal error. | { "code": "string", "message": "string" }
|
||||||||||
503 | Service Unavailable | { "code": "string", "message": "string" }
|