Python
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
role_assignment_updated_deleted = client.cloud.users.role_assignments.update(
assignment_id=123,
role="ClientAdministrator",
user_id=777,
)
print(role_assignment_updated_deleted.assignment_id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cloud"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
roleAssignmentUpdatedDeleted, err := client.Cloud.Users.RoleAssignments.Update(
context.TODO(),
123,
cloud.UserRoleAssignmentUpdateParams{
Role: cloud.UserRoleAssignmentUpdateParamsRoleClientAdministrator,
UserID: 777,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", roleAssignmentUpdatedDeleted.AssignmentID)
}
curl --request PATCH \
--url https://api.gcore.com/cloud/v1/users/assignments/{assignment_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"user_id": 777,
"client_id": 8,
"project_id": null
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({user_id: 777, client_id: 8, project_id: null})
};
fetch('https://api.gcore.com/cloud/v1/users/assignments/{assignment_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/cloud/v1/users/assignments/{assignment_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'user_id' => 777,
'client_id' => 8,
'project_id' => null
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.patch("https://api.gcore.com/cloud/v1/users/assignments/{assignment_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"user_id\": 777,\n \"client_id\": 8,\n \"project_id\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/users/assignments/{assignment_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_id\": 777,\n \"client_id\": 8,\n \"project_id\": null\n}"
response = http.request(request)
puts response.read_body{
"assignment_id": 12
}User Role Assignments
Update role assignment
Modify an existing role assignment for a user.
PATCH
/
cloud
/
v1
/
users
/
assignments
/
{assignment_id}
Python
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
role_assignment_updated_deleted = client.cloud.users.role_assignments.update(
assignment_id=123,
role="ClientAdministrator",
user_id=777,
)
print(role_assignment_updated_deleted.assignment_id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/cloud"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
roleAssignmentUpdatedDeleted, err := client.Cloud.Users.RoleAssignments.Update(
context.TODO(),
123,
cloud.UserRoleAssignmentUpdateParams{
Role: cloud.UserRoleAssignmentUpdateParamsRoleClientAdministrator,
UserID: 777,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", roleAssignmentUpdatedDeleted.AssignmentID)
}
curl --request PATCH \
--url https://api.gcore.com/cloud/v1/users/assignments/{assignment_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"user_id": 777,
"client_id": 8,
"project_id": null
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({user_id: 777, client_id: 8, project_id: null})
};
fetch('https://api.gcore.com/cloud/v1/users/assignments/{assignment_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/cloud/v1/users/assignments/{assignment_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'user_id' => 777,
'client_id' => 8,
'project_id' => null
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.patch("https://api.gcore.com/cloud/v1/users/assignments/{assignment_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"user_id\": 777,\n \"client_id\": 8,\n \"project_id\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/users/assignments/{assignment_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_id\": 777,\n \"client_id\": 8,\n \"project_id\": null\n}"
response = http.request(request)
puts response.read_body{
"assignment_id": 12
}Authorizations
API key for authentication. Make sure to include the word apikey, followed by a single space and then your token.
Example: apikey 1234$abcdef
Path Parameters
Assignment ID
Example:
123
Body
application/json
User role
Available options:
ClientAdministrator, InternalNetworkOnlyUser, Observer, ProjectAdministrator, User Example:
"ClientAdministrator"
User ID
Example:
777
Client ID. Required if project_id is specified
Example:
8
Project ID
Example:
null
Response
200 - application/json
OK
Assignment ID
Example:
12
Was this page helpful?
⌘I