import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
page = client.cloud.audit_logs.list()
page = page.results[0]
print(page.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"),
)
page, err := client.Cloud.AuditLogs.List(context.TODO(), cloud.AuditLogListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
curl --request GET \
--url https://api.gcore.com/cloud/v1/user_actions \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cloud/v1/user_actions', 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/user_actions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/cloud/v1/user_actions")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/user_actions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"count": 1,
"results": [
{
"acknowledged": true,
"action_data": "{\"name\": \"test_project_a\"}",
"action_type": "create",
"api_group": "project",
"client_id": 10,
"email": "user@example.com",
"id": "123",
"is_complete": true,
"issued_by_user_id": 222324,
"project_id": 1,
"region_id": 4,
"resources": [
{
"resource_id": "1234",
"resource_type": "project",
"resource_body": {
"key": "value"
},
"search_field": "name"
}
],
"source_user_ip": "1.2.3.4",
"task_id": "1bdcc138-e716-41ff-ad8d-3477a7ac6d14",
"timestamp": "2019-11-14T10:30:32+00:00",
"token_id": 192021,
"total_price": {
"currency_code": "USD",
"price_per_hour": 0.01,
"price_per_month": 7.2,
"price_status": "show"
},
"user_agent": "Mozilla/5.0",
"user_id": 789
}
]
}List user actions
Retrieve user action log for one client or a set of projects
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
page = client.cloud.audit_logs.list()
page = page.results[0]
print(page.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"),
)
page, err := client.Cloud.AuditLogs.List(context.TODO(), cloud.AuditLogListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
curl --request GET \
--url https://api.gcore.com/cloud/v1/user_actions \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/cloud/v1/user_actions', 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/user_actions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/cloud/v1/user_actions")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/user_actions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"count": 1,
"results": [
{
"acknowledged": true,
"action_data": "{\"name\": \"test_project_a\"}",
"action_type": "create",
"api_group": "project",
"client_id": 10,
"email": "user@example.com",
"id": "123",
"is_complete": true,
"issued_by_user_id": 222324,
"project_id": 1,
"region_id": 4,
"resources": [
{
"resource_id": "1234",
"resource_type": "project",
"resource_body": {
"key": "value"
},
"search_field": "name"
}
],
"source_user_ip": "1.2.3.4",
"task_id": "1bdcc138-e716-41ff-ad8d-3477a7ac6d14",
"timestamp": "2019-11-14T10:30:32+00:00",
"token_id": 192021,
"total_price": {
"currency_code": "USD",
"price_per_hour": 0.01,
"price_per_month": 7.2,
"price_status": "show"
},
"user_agent": "Mozilla/5.0",
"user_id": 789
}
]
}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
Query Parameters
User action type. Several options can be specified.
activate, attach, change_logging_resources, create, create_access_rule, deactivate, delete, delete_access_rule, delete_metadata, detach, disable_logging, disable_portsecurity, download, enable_logging, enable_portsecurity, failover, put_into_servergroup, reboot, reboot_hard, rebuild, regenerate_credentials, remove_from_servergroup, replace, replace_metadata, resize, resume, retype, revert, scale_down, scale_up, start, stop, suspend, update, update_metadata, upgrade ["activate", "delete"]
API group that requested action belongs to. Several options can be specified.
ai_cluster, caas_container, caas_key, caas_pull_secret, dbaas_postgres, ddos_profile, faas_function, faas_key, faas_namespace, file_shares, floating_ip, image, inference_at_the_edge, instance, instance_isolation, k8s_cluster, k8s_cluster_template, k8s_pool, laas, laas_topic, lb_health_monitor, lb_l7policy, lb_l7rule, lblistener, lbpool, lbpool_member, lifecycle_policy, lifecycle_policy_volume_member, loadbalancer, network, port, project, quota_limit_request, registry, reservation, reserved_fixed_ip, role, router, secret, securitygroup, securitygrouprule, servergroup, shared_flavor, shared_image, shared_network, snapshot, snapshot_schedule, ssh_key, subnet, user, vip_ip_addresses, volume ["ai_cluster", "image"]
ISO formatted datetime string. Starting timestamp from which user actions are requested
"2019-11-14T10:30:32Z"
Optional. Limit the number of returned items
x <= 10001000
Optional. Offset value is used to exclude the first set of records from the result
x >= 00
Sorting by timestamp. Oldest first, or most recent first
asc, desc "asc"
Project ID. Several options can be specified.
[1, 2, 3]
Region ID. Several options can be specified.
[1, 2, 3]
Resource ID. Several options can be specified.
Extra search field for common object properties such as name, IP address, or other, depending on the resource_type
"default"
(DEPRECATED Use 'order_by' instead) Sorting by timestamp. Oldest first, or most recent first
asc, desc "asc"
Originating IP address of the client making the request. Several options can be specified.
["203.0.113.42", "192.168.1.100"]
ISO formatted datetime string. Ending timestamp until which user actions are requested
"2019-11-14T10:30:32Z"
User-Agent string identifying the client making the request. Several options can be specified.
["Mozilla/5.0", "MyApp/1.0.0"]
Was this page helpful?