Criar uma função personalizada
Requer um proprietário ou administrador atual da organização humana, além de write:org para tokens OAuth e chaves de API. Contas de serviço são recusadas, incluindo as administrativas. Escritas pelo navegador exigem uma sessão ativa não armazenada em cache e um Origin confiável. Um papel é um nome e um conjunto de escopos. O nome tem de ter de 1 a 64 caracteres após a normalização Unicode NFKC, não pode conter vírgula, caractere de controle ou invisível, deve ser único na organização ignorando maiúsculas e minúsculas, e não pode ser owner, admin ou member. Cada escopo deve estar em supportedScopes; qualquer outro escopo retorna 400 ROLE_SCOPES_UNSUPPORTED. Um nome já em uso retorna 409 ROLE_NAME_TAKEN, e o 101º papel retorna 409 ROLE_LIMIT_REACHED.
using MeetKai.MKA1;
using MeetKai.MKA1.Types.Requests;
using System.Collections.Generic;
var sdk = new SDK();
var res = await sdk.Auth.Orgs.CreateRoleAsync(
security: new CreateOrgRoleSecurity() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
},
orgId: "<id>",
body: new CreateOrgRoleRequestBody() {
Name = "<value>",
Scopes = new List<string>() {
"<value 1>",
"<value 2>",
"<value 3>",
},
}
);
// handle responsefrom meetkai_mka1 import SDK, models
with SDK() as sdk:
res = sdk.auth.orgs.create_role(security=models.CreateOrgRoleSecurity(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
), org_id="<id>", name="<value>", scopes=[
"<value 1>",
"<value 2>",
"<value 3>",
])
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK();
async function run() {
const result = await sdk.auth.orgs.createRole({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
}, {
orgId: "<id>",
requestBody: {
name: "<value>",
scopes: [
"<value 1>",
"<value 2>",
"<value 3>",
],
},
});
console.log(result);
}
run();package main
import(
"context"
mka1 "github.com/MeetKai/mka1-sdks/go"
"github.com/MeetKai/mka1-sdks/go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := mka1.New()
res, err := s.Auth.Orgs.CreateRole(ctx, operations.CreateOrgRoleSecurity{
BearerAuth: mka1.Pointer("<YOUR_BEARER_TOKEN_HERE>"),
}, "<id>", operations.CreateOrgRoleRequestBody{
Name: "<value>",
Scopes: []string{
"<value 1>",
"<value 2>",
"<value 3>",
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}curl --request POST \
--url https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"scopes": [
"<string>"
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', scopes: ['<string>']})
};
fetch('https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles', 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://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles",
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([
'name' => '<string>',
'scopes' => [
'<string>'
]
]),
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;
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scopes\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles")
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 \"name\": \"<string>\",\n \"scopes\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"role": {
"id": "<string>",
"organizationId": "<string>",
"name": "<string>",
"scopes": [
"<string>"
],
"createdAt": "<string>",
"updatedAt": "<string>"
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Autorizações
Corpo
Esta página foi útil?
using MeetKai.MKA1;
using MeetKai.MKA1.Types.Requests;
using System.Collections.Generic;
var sdk = new SDK();
var res = await sdk.Auth.Orgs.CreateRoleAsync(
security: new CreateOrgRoleSecurity() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
},
orgId: "<id>",
body: new CreateOrgRoleRequestBody() {
Name = "<value>",
Scopes = new List<string>() {
"<value 1>",
"<value 2>",
"<value 3>",
},
}
);
// handle responsefrom meetkai_mka1 import SDK, models
with SDK() as sdk:
res = sdk.auth.orgs.create_role(security=models.CreateOrgRoleSecurity(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
), org_id="<id>", name="<value>", scopes=[
"<value 1>",
"<value 2>",
"<value 3>",
])
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK();
async function run() {
const result = await sdk.auth.orgs.createRole({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
}, {
orgId: "<id>",
requestBody: {
name: "<value>",
scopes: [
"<value 1>",
"<value 2>",
"<value 3>",
],
},
});
console.log(result);
}
run();package main
import(
"context"
mka1 "github.com/MeetKai/mka1-sdks/go"
"github.com/MeetKai/mka1-sdks/go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := mka1.New()
res, err := s.Auth.Orgs.CreateRole(ctx, operations.CreateOrgRoleSecurity{
BearerAuth: mka1.Pointer("<YOUR_BEARER_TOKEN_HERE>"),
}, "<id>", operations.CreateOrgRoleRequestBody{
Name: "<value>",
Scopes: []string{
"<value 1>",
"<value 2>",
"<value 3>",
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}curl --request POST \
--url https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"scopes": [
"<string>"
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', scopes: ['<string>']})
};
fetch('https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles', 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://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles",
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([
'name' => '<string>',
'scopes' => [
'<string>'
]
]),
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;
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scopes\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles")
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 \"name\": \"<string>\",\n \"scopes\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"role": {
"id": "<string>",
"organizationId": "<string>",
"name": "<string>",
"scopes": [
"<string>"
],
"createdAt": "<string>",
"updatedAt": "<string>"
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}