Skip to content

Latest commit

 

History

History
510 lines (316 loc) · 12.1 KB

TokensAPI.md

File metadata and controls

510 lines (316 loc) · 12.1 KB

TokensAPI

Note

All URIs are relative to https://api.fastly.com

Method HTTP request Description
BulkRevokeTokens DELETE /tokens Revoke multiple tokens
CreateToken POST /tokens Create a token
GetToken GET /tokens/{token_id} Get a token
GetTokenCurrent GET /tokens/self Get the current token
ListTokensCustomer GET /customer/{customer_id}/tokens List tokens for a customer
ListTokensUser GET /tokens List tokens for the authenticated user
RevokeToken DELETE /tokens/{token_id} Revoke a token
RevokeTokenCurrent DELETE /tokens/self Revoke the current token

BulkRevokeTokens

Revoke multiple tokens

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    requestBody := map[string]map[string]any{"key": map[string]any(123)} // map[string]map[string]any |  (optional)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.TokensAPI.BulkRevokeTokens(ctx).RequestBody(requestBody).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `TokensAPI.BulkRevokeTokens`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiBulkRevokeTokensRequest struct via the builder pattern

Name Type Description Notes
requestBody map[string]map[string]any

Return type

(empty response body)

Authorization

API Token

HTTP request headers

  • Content-Type: application/vnd.api+json; ext=bulk
  • Accept: Not defined

Back to top | Back to API list | Back to README

CreateToken

Create a token

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.TokensAPI.CreateToken(ctx).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `TokensAPI.CreateToken`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateToken`: TokenCreatedResponse
    fmt.Fprintf(os.Stdout, "Response from `TokensAPI.CreateToken`: %v\n", resp)
}

Path Parameters

This endpoint does not need any parameter.

Other Parameters

Other parameters are passed through a pointer to a apiCreateTokenRequest struct via the builder pattern

Return type

TokenCreatedResponse

Authorization

API TokenAPI Token

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

Back to top | Back to API list | Back to README

GetToken

Get a token

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    tokenID := "tokenId_example" // string | Alphanumeric string identifying a token.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.TokensAPI.GetToken(ctx, tokenID).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `TokensAPI.GetToken`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetToken`: TokenResponse
    fmt.Fprintf(os.Stdout, "Response from `TokensAPI.GetToken`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
tokenID string Alphanumeric string identifying a token.

Other Parameters

Other parameters are passed through a pointer to a apiGetTokenRequest struct via the builder pattern

Name Type Description Notes

Return type

TokenResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

GetTokenCurrent

Get the current token

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.TokensAPI.GetTokenCurrent(ctx).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `TokensAPI.GetTokenCurrent`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetTokenCurrent`: TokenResponse
    fmt.Fprintf(os.Stdout, "Response from `TokensAPI.GetTokenCurrent`: %v\n", resp)
}

Path Parameters

This endpoint does not need any parameter.

Other Parameters

Other parameters are passed through a pointer to a apiGetTokenCurrentRequest struct via the builder pattern

Return type

TokenResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

ListTokensCustomer

List tokens for a customer

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    customerID := "customerId_example" // string | Alphanumeric string identifying the customer.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.TokensAPI.ListTokensCustomer(ctx, customerID).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `TokensAPI.ListTokensCustomer`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListTokensCustomer`: []TokenResponse
    fmt.Fprintf(os.Stdout, "Response from `TokensAPI.ListTokensCustomer`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
customerID string Alphanumeric string identifying the customer.

Other Parameters

Other parameters are passed through a pointer to a apiListTokensCustomerRequest struct via the builder pattern

Name Type Description Notes

Return type

[]TokenResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

ListTokensUser

List tokens for the authenticated user

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.TokensAPI.ListTokensUser(ctx).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `TokensAPI.ListTokensUser`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListTokensUser`: []TokenResponse
    fmt.Fprintf(os.Stdout, "Response from `TokensAPI.ListTokensUser`: %v\n", resp)
}

Path Parameters

This endpoint does not need any parameter.

Other Parameters

Other parameters are passed through a pointer to a apiListTokensUserRequest struct via the builder pattern

Return type

[]TokenResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

RevokeToken

Revoke a token

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    tokenID := "tokenId_example" // string | Alphanumeric string identifying a token.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.TokensAPI.RevokeToken(ctx, tokenID).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `TokensAPI.RevokeToken`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
tokenID string Alphanumeric string identifying a token.

Other Parameters

Other parameters are passed through a pointer to a apiRevokeTokenRequest struct via the builder pattern

Name Type Description Notes

Return type

(empty response body)

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

RevokeTokenCurrent

Revoke the current token

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.TokensAPI.RevokeTokenCurrent(ctx).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `TokensAPI.RevokeTokenCurrent`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
}

Path Parameters

This endpoint does not need any parameter.

Other Parameters

Other parameters are passed through a pointer to a apiRevokeTokenCurrentRequest struct via the builder pattern

Return type

(empty response body)

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README