Skip to content

Latest commit

 

History

History
370 lines (283 loc) · 10.8 KB

orgs-api-tokens.md

File metadata and controls

370 lines (283 loc) · 10.8 KB

Orgs API Tokens

orgsAPITokens := client.OrgsAPITokens()

Class Name

OrgsAPITokens

Methods

Create Org Api Token

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)

Parameters

Parameter Type Tags Description
orgId uuid.UUID Template, Required -
body *models.OrgApitoken Body, Optional -

Response Type

models.OrgApitoken

Example Usage

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"
    }
  ]
}

Errors

HTTP Status Code Error Description Exception Class
400 Bad Syntax ResponseHttp400Exception
401 Unauthorized ResponseHttp401ErrorException
403 Permission Denied ResponseHttp403ErrorException
404 Not found. The API endpoint doesn’t exist or resource doesn’ t exist ResponseHttp404Exception
429 Too Many Request. The API Token used for the request reached the 5000 API Calls per hour threshold ResponseHttp429ErrorException

Delete Org Api Token

Delete Org API Token

DeleteOrgApiToken(
    ctx context.Context,
    orgId uuid.UUID,
    apitokenId uuid.UUID) (
    http.Response,
    error)

Parameters

Parameter Type Tags Description
orgId uuid.UUID Template, Required -
apitokenId uuid.UUID Template, Required -

Response Type

``

Example Usage

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)
}

Errors

HTTP Status Code Error Description Exception Class
400 Bad Syntax ResponseHttp400Exception
401 Unauthorized ResponseHttp401ErrorException
403 Permission Denied ResponseHttp403ErrorException
404 Not found. The API endpoint doesn’t exist or resource doesn’ t exist ResponseHttp404Exception
429 Too Many Request. The API Token used for the request reached the 5000 API Calls per hour threshold ResponseHttp429ErrorException

Get Org Api Token

Get Org API Token

GetOrgApiToken(
    ctx context.Context,
    orgId uuid.UUID,
    apitokenId uuid.UUID) (
    models.ApiResponse[models.OrgApitoken],
    error)

Parameters

Parameter Type Tags Description
orgId uuid.UUID Template, Required -
apitokenId uuid.UUID Template, Required -

Response Type

models.OrgApitoken

Example Usage

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"
    }
  ]
}

Errors

HTTP Status Code Error Description Exception Class
400 Bad Syntax ResponseHttp400Exception
401 Unauthorized ResponseHttp401ErrorException
403 Permission Denied ResponseHttp403ErrorException
404 Not found. The API endpoint doesn’t exist or resource doesn’ t exist ResponseHttp404Exception
429 Too Many Request. The API Token used for the request reached the 5000 API Calls per hour threshold ResponseHttp429ErrorException

List Org Api Tokens

Get List of Org API Tokens

ListOrgApiTokens(
    ctx context.Context,
    orgId uuid.UUID) (
    models.ApiResponse[[]models.OrgApitoken],
    error)

Parameters

Parameter Type Tags Description
orgId uuid.UUID Template, Required -

Response Type

[]models.OrgApitoken

Example Usage

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"
      }
    ]
  }
]

Errors

HTTP Status Code Error Description Exception Class
400 Bad Syntax ResponseHttp400Exception
401 Unauthorized ResponseHttp401ErrorException
403 Permission Denied ResponseHttp403ErrorException
404 Not found. The API endpoint doesn’t exist or resource doesn’ t exist ResponseHttp404Exception
429 Too Many Request. The API Token used for the request reached the 5000 API Calls per hour threshold ResponseHttp429ErrorException

Update Org Api Token

Update Org API Token

UpdateOrgApiToken(
    ctx context.Context,
    orgId uuid.UUID,
    apitokenId uuid.UUID,
    body *models.OrgApitoken) (
    http.Response,
    error)

Parameters

Parameter Type Tags Description
orgId uuid.UUID Template, Required -
apitokenId uuid.UUID Template, Required -
body *models.OrgApitoken Body, Optional Request Body

Response Type

``

Example Usage

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)
}

Errors

HTTP Status Code Error Description Exception Class
400 Bad Syntax ResponseHttp400Exception
401 Unauthorized ResponseHttp401ErrorException
403 Permission Denied ResponseHttp403ErrorException
404 Not found. The API endpoint doesn’t exist or resource doesn’ t exist ResponseHttp404Exception
429 Too Many Request. The API Token used for the request reached the 5000 API Calls per hour threshold ResponseHttp429ErrorException