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
)
access_rule = client.cloud.file_shares.access_rules.create(
file_share_id="bd8c47ee-e565-4e26-8840-b537e6827b08",
project_id=1,
region_id=1,
access_mode="ro",
ip_address="192.168.1.1",
)
print(access_rule.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"),
)
accessRule, err := client.Cloud.FileShares.AccessRules.New(
context.TODO(),
"bd8c47ee-e565-4e26-8840-b537e6827b08",
cloud.FileShareAccessRuleNewParams{
ProjectID: gcore.Int(1),
RegionID: gcore.Int(1),
AccessMode: cloud.FileShareAccessRuleNewParamsAccessModeRo,
IPAddress: "192.168.1.1",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", accessRule.ID)
}curl --request POST \
--url https://api.gcore.com/cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}/access_rule \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"ip_address": "192.168.1.1"
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({ip_address: '192.168.1.1'})
};
fetch('https://api.gcore.com/cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}/access_rule', 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/file_shares/{project_id}/{region_id}/{file_share_id}/access_rule",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ip_address' => '192.168.1.1'
]),
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.post("https://api.gcore.com/cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}/access_rule")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ip_address\": \"192.168.1.1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}/access_rule")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ip_address\": \"192.168.1.1\"\n}"
response = http.request(request)
puts response.read_body{
"access_to": "192.168.1.1",
"id": "4f09d7dd-f1f8-4352-b015-741b2192db47"
}File Shares
Create file share access rule
POST
/
cloud
/
v1
/
file_shares
/
{project_id}
/
{region_id}
/
{file_share_id}
/
access_rule
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
)
access_rule = client.cloud.file_shares.access_rules.create(
file_share_id="bd8c47ee-e565-4e26-8840-b537e6827b08",
project_id=1,
region_id=1,
access_mode="ro",
ip_address="192.168.1.1",
)
print(access_rule.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"),
)
accessRule, err := client.Cloud.FileShares.AccessRules.New(
context.TODO(),
"bd8c47ee-e565-4e26-8840-b537e6827b08",
cloud.FileShareAccessRuleNewParams{
ProjectID: gcore.Int(1),
RegionID: gcore.Int(1),
AccessMode: cloud.FileShareAccessRuleNewParamsAccessModeRo,
IPAddress: "192.168.1.1",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", accessRule.ID)
}curl --request POST \
--url https://api.gcore.com/cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}/access_rule \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"ip_address": "192.168.1.1"
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({ip_address: '192.168.1.1'})
};
fetch('https://api.gcore.com/cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}/access_rule', 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/file_shares/{project_id}/{region_id}/{file_share_id}/access_rule",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ip_address' => '192.168.1.1'
]),
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.post("https://api.gcore.com/cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}/access_rule")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ip_address\": \"192.168.1.1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/cloud/v1/file_shares/{project_id}/{region_id}/{file_share_id}/access_rule")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ip_address\": \"192.168.1.1\"\n}"
response = http.request(request)
puts response.read_body{
"access_to": "192.168.1.1",
"id": "4f09d7dd-f1f8-4352-b015-741b2192db47"
}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
Project ID
Example:
1
Region ID
Example:
1
File Share ID
Example:
"bd8c47ee-e565-4e26-8840-b537e6827b08"
Body
application/json
Response
200 - application/json
OK
Access mode
Available options:
ro, rw Example:
"ro"
Source IP or network
Example:
"192.168.1.1"
Access Rule ID
Example:
"4f09d7dd-f1f8-4352-b015-741b2192db47"
Access Rule state
Available options:
active, applying, denying, error, new, queued_to_apply, queued_to_deny Example:
"active"
Was this page helpful?
⌘I