Skip to main content
POST
/
resources
/
update-access
Update access type
curl --request POST \
  --url https://api-dev.narrative.io/resources/update-access \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "bucket_name": "nio-yourcompany-iwhhrql8sgvp",
  "new_access": {
    "type": "bucket_policy"
  }
}
'
import requests

url = "https://api-dev.narrative.io/resources/update-access"

payload = {
"bucket_name": "nio-yourcompany-iwhhrql8sgvp",
"new_access": { "type": "bucket_policy" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
bucket_name: 'nio-yourcompany-iwhhrql8sgvp',
new_access: {type: 'bucket_policy'}
})
};

fetch('https://api-dev.narrative.io/resources/update-access', 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-dev.narrative.io/resources/update-access",
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([
'bucket_name' => 'nio-yourcompany-iwhhrql8sgvp',
'new_access' => [
'type' => 'bucket_policy'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

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

func main() {

url := "https://api-dev.narrative.io/resources/update-access"

payload := strings.NewReader("{\n \"bucket_name\": \"nio-yourcompany-iwhhrql8sgvp\",\n \"new_access\": {\n \"type\": \"bucket_policy\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/resources/update-access")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"bucket_name\": \"nio-yourcompany-iwhhrql8sgvp\",\n \"new_access\": {\n \"type\": \"bucket_policy\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api-dev.narrative.io/resources/update-access")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"bucket_name\": \"nio-yourcompany-iwhhrql8sgvp\",\n \"new_access\": {\n \"type\": \"bucket_policy\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "45b40bf5-02fc-4f18-bfcd-50ac58dabfa1",
  "company_id": 1,
  "auth": {
    "type": "bucket_policy",
    "account_id": "123456789012"
  },
  "name": "nio-yourcompany-821627dd2931",
  "created_at": "2021-08-31T20:22:02Z",
  "updated_at": "2021-08-31T20:22:02Z"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
bucket_name
string

Full name of the bucket that should be affected.

Example:

"nio-yourcompany-iwhhrql8sgvp"

new_access
object
Example:
{ "type": "bucket_policy" }

Response

200 - application/json

OK

An AWS S3 bucket created inside Narrative's AWS account assigned to a specific company.

id
string

Unique identifier for the bucket.

Example:

"4d5451ff-5fe6-4db3-9398-4075bbd275b0"

auth
object
company_id
integer

The ID of the company owning the bucket.

name
string

The AWS S3 bucket name. The bucket name is of the form nio-${resource_id}-${suffix} where resouce_id is the resource ID provided at bucket creation and suffix is 12 randomly chosen alphanumeric characters.

A random suffix is appended to the bucket name for two reasons:

  • AWS S3 bucket names must be globally unique, i.e. the bucket namespace is shared by all AWS accounts. Appending a random suffix helps ensure that we can create a bucket which includes your preferred resource ID.
  • Another consequence of AWS S3 bucket names needing to be globally unique is that anyone can easily check if a bucket with a given name exists. By appending a random suffix to your bucket we are preventing information leakage by making it impractical for an attacker to determine whether you are a customer of Narrative by simply guessing your resource ID and checking whether a bucket with the name nio-${resource_id} exists.
Example:

"nio-yourcompanyname-50ac58dabfa1"

created_at
string

ISO-8601 timestamp indicating when the bucket was created.

Example:

"2021-08-26T21:06:07.710357Z"

updated_at
string

ISO-8601 timestamp indicating when the bucket was last updated.

Example:

"2021-08-26T21:06:07.710357Z"

is_access_mutable
boolean

Is it allowed to change access type. Changes are allowed by default. Restrictions could be applied in case bucket was manually config