Skip to content

Latest commit

 

History

History
176 lines (129 loc) · 8.61 KB

README.md

File metadata and controls

176 lines (129 loc) · 8.61 KB

TokensV1

(TokensV1)

Overview

Available Operations

GetOrgTokens

List all organization tokens for a given org.

Example Usage

package main

import(
	"context"
	"hathoracloud"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := hathoracloud.New(
        hathoracloud.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
        hathoracloud.WithOrgID("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39"),
        hathoracloud.WithAppID("app-af469a92-5b45-4565-b3c4-b79878de67d2"),
    )

    res, err := s.TokensV1.GetOrgTokens(ctx, "org-6f706e83-0ec1-437a-9a46-7d4281eb2f39")
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
orgID string ✔️ N/A org-6f706e83-0ec1-437a-9a46-7d4281eb2f39
opts []operations.Option The options for this request.

Response

*components.ListOrgTokens, error

Errors

Error Type Status Code Content Type
errors.APIError 401, 404, 429 application/json
errors.SDKError 4XX, 5XX */*

CreateOrgToken

Create a new organization token.

Example Usage

package main

import(
	"context"
	"hathoracloud"
	"hathoracloud/models/components"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := hathoracloud.New(
        hathoracloud.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
        hathoracloud.WithOrgID("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39"),
        hathoracloud.WithAppID("app-af469a92-5b45-4565-b3c4-b79878de67d2"),
    )

    res, err := s.TokensV1.CreateOrgToken(ctx, "org-6f706e83-0ec1-437a-9a46-7d4281eb2f39", components.CreateOrgToken{
        Name: "ci-token",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
orgID string ✔️ N/A org-6f706e83-0ec1-437a-9a46-7d4281eb2f39
createOrgToken components.CreateOrgToken ✔️ N/A
opts []operations.Option The options for this request.

Response

*components.CreatedOrgToken, error

Errors

Error Type Status Code Content Type
errors.APIError 401, 404, 422, 429 application/json
errors.SDKError 4XX, 5XX */*

RevokeOrgToken

Revoke an organization token.

Example Usage

package main

import(
	"context"
	"hathoracloud"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := hathoracloud.New(
        hathoracloud.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
        hathoracloud.WithOrgID("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39"),
        hathoracloud.WithAppID("app-af469a92-5b45-4565-b3c4-b79878de67d2"),
    )

    res, err := s.TokensV1.RevokeOrgToken(ctx, "org-6f706e83-0ec1-437a-9a46-7d4281eb2f39", "org-token-af469a92-5b45-4565-b3c4-b79878de67d2")
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description Example
ctx context.Context ✔️ The context to use for the request.
orgID string ✔️ N/A org-6f706e83-0ec1-437a-9a46-7d4281eb2f39
orgTokenID string ✔️ N/A org-token-af469a92-5b45-4565-b3c4-b79878de67d2
opts []operations.Option The options for this request.

Response

*bool, error

Errors

Error Type Status Code Content Type
errors.APIError 401, 404, 429 application/json
errors.SDKError 4XX, 5XX */*