orgsAPITokens := client .OrgsAPITokens ()
OrgsAPITokens
Create Org API Token
Note that the token key is only available during creation time.
CreateOrgApiToken (
ctx context .Context ,
orgId uuid .UUID ,
body * models .OrgApitoken ) (
models .ApiResponse [models .OrgApitoken ],
error )
Parameter
Type
Tags
Description
orgId
uuid.UUID
Template, Required
-
body
*models.OrgApitoken
Body, Optional
-
models.OrgApitoken
ctx := context .Background ()
orgId := uuid .MustParse ("000000ab-00ab-00ab-00ab-0000000000ab" )
body := models.OrgApitoken {
Name : "org_token_xyz" ,
Privileges : []models.PrivilegeOrg {
models.PrivilegeOrg {
Role : models .PrivilegeOrgRoleEnum ("admin" ),
Scope : models .PrivilegeOrgScopeEnum ("org" ),
},
},
SrcIps : []string {
"63.3.56.0/24" ,
"63.3.55.4" ,
},
}
apiResponse , err := orgsAPITokens .CreateOrgApiToken (ctx , orgId , & body )
if err != nil {
log .Fatalln (err )
} else {
// Printing the result and response
fmt .Println (apiResponse .Data )
fmt .Println (apiResponse .Response .StatusCode )
}
Example Response (as JSON)
{
"created_by" : " user@mycorp.com" ,
"created_time" : 1626875902 ,
"id" : " 497f6eca-6276-4993-bfeb-53efbbba6f08" ,
"key" : " 1qkb...QQCL" ,
"last_used" : 1690115110 ,
"name" : " org_token_xyz" ,
"org_id" : " a40f5d1f-d889-42e9-94ea-b9b33585fc6b" ,
"privileges" : [
{
"org_id" : " a40f5d1f-d889-42e9-94ea-b9b33585fc6b" ,
"role" : " admin" ,
"scope" : " org"
}
]
}
Delete Org API Token
DeleteOrgApiToken (
ctx context .Context ,
orgId uuid .UUID ,
apitokenId uuid .UUID ) (
http .Response ,
error )
Parameter
Type
Tags
Description
orgId
uuid.UUID
Template, Required
-
apitokenId
uuid.UUID
Template, Required
-
``
ctx := context .Background ()
orgId := uuid .MustParse ("000000ab-00ab-00ab-00ab-0000000000ab" )
apitokenId := uuid .MustParse ("000000ab-00ab-00ab-00ab-0000000000ab" )
resp , err := orgsAPITokens .DeleteOrgApiToken (ctx , orgId , apitokenId )
if err != nil {
log .Fatalln (err )
} else {
fmt .Println (resp .StatusCode )
}
Get Org API Token
GetOrgApiToken (
ctx context .Context ,
orgId uuid .UUID ,
apitokenId uuid .UUID ) (
models .ApiResponse [models .OrgApitoken ],
error )
Parameter
Type
Tags
Description
orgId
uuid.UUID
Template, Required
-
apitokenId
uuid.UUID
Template, Required
-
models.OrgApitoken
ctx := context .Background ()
orgId := uuid .MustParse ("000000ab-00ab-00ab-00ab-0000000000ab" )
apitokenId := uuid .MustParse ("000000ab-00ab-00ab-00ab-0000000000ab" )
apiResponse , err := orgsAPITokens .GetOrgApiToken (ctx , orgId , apitokenId )
if err != nil {
log .Fatalln (err )
} else {
// Printing the result and response
fmt .Println (apiResponse .Data )
fmt .Println (apiResponse .Response .StatusCode )
}
Example Response (as JSON)
{
"created_by" : " user@mycorp.com" ,
"created_time" : 1626875902 ,
"id" : " 497f6eca-6276-4993-bfeb-53efbbba6f08" ,
"key" : " 1qkb...QQCL" ,
"last_used" : 1690115110 ,
"name" : " org_token_xyz" ,
"org_id" : " a40f5d1f-d889-42e9-94ea-b9b33585fc6b" ,
"privileges" : [
{
"org_id" : " a40f5d1f-d889-42e9-94ea-b9b33585fc6b" ,
"role" : " admin" ,
"scope" : " org"
}
]
}
Get List of Org API Tokens
ListOrgApiTokens (
ctx context .Context ,
orgId uuid .UUID ) (
models.ApiResponse [[]models.OrgApitoken ],
error )
Parameter
Type
Tags
Description
orgId
uuid.UUID
Template, Required
-
[]models.OrgApitoken
ctx := context .Background ()
orgId := uuid .MustParse ("000000ab-00ab-00ab-00ab-0000000000ab" )
apiResponse , err := orgsAPITokens .ListOrgApiTokens (ctx , orgId )
if err != nil {
log .Fatalln (err )
} else {
// Printing the result and response
fmt .Println (apiResponse .Data )
fmt .Println (apiResponse .Response .StatusCode )
}
Example Response (as JSON)
[
{
"created_by" : " user@mycorp.com" ,
"created_time" : 1626875902 ,
"id" : " 497f6eca-6276-4993-bfeb-53f0bbba6f08" ,
"key" : " 1qkb...QQCL" ,
"last_used" : 1690115110 ,
"name" : " org_token_xyz" ,
"org_id" : " a40f5d1f-d889-42e9-94ea-b9b33585fc6b" ,
"privileges" : [
{
"org_id" : " a40f5d1f-d889-42e9-94ea-b9b33585fc6b" ,
"role" : " admin" ,
"scope" : " org"
}
]
}
]
Update Org API Token
UpdateOrgApiToken (
ctx context .Context ,
orgId uuid .UUID ,
apitokenId uuid .UUID ,
body * models .OrgApitoken ) (
http .Response ,
error )
Parameter
Type
Tags
Description
orgId
uuid.UUID
Template, Required
-
apitokenId
uuid.UUID
Template, Required
-
body
*models.OrgApitoken
Body, Optional
Request Body
``
ctx := context .Background ()
orgId := uuid .MustParse ("000000ab-00ab-00ab-00ab-0000000000ab" )
apitokenId := uuid .MustParse ("000000ab-00ab-00ab-00ab-0000000000ab" )
body := models.OrgApitoken {
Name : "org_token_xyz" ,
Privileges : []models.PrivilegeOrg {
models.PrivilegeOrg {
Role : models .PrivilegeOrgRoleEnum ("admin" ),
Scope : models .PrivilegeOrgScopeEnum ("org" ),
},
},
}
resp , err := orgsAPITokens .UpdateOrgApiToken (ctx , orgId , apitokenId , & body )
if err != nil {
log .Fatalln (err )
} else {
fmt .Println (resp .StatusCode )
}