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 |
Revoke multiple tokens
package main
import (
"context"
"fmt"
"os"
"github.com/fastly/fastly-go/fastly"
)
func main() {
requestBody := map[string]map[string]interface{}{"key": map[string]interface{}(123)} // map[string]map[string]interface{} | (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)
}
}Other parameters are passed through a pointer to a apiBulkRevokeTokensRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|---|---|---|
| requestBody | map[string]map[string]interface{} |
(empty response body)
- Content-Type: application/vnd.api+json; ext=bulk
- Accept: Not defined
Back to top | Back to API list | Back to README
Create a token
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)
}This endpoint does not need any parameter.
Other parameters are passed through a pointer to a apiCreateTokenRequest struct via the builder pattern
- Content-Type: application/x-www-form-urlencoded
- Accept: application/json
Back to top | Back to API list | Back to README
Get a token
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)
}| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
| tokenId | string | Alphanumeric string identifying a token. |
Other parameters are passed through a pointer to a apiGetTokenRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|
- Content-Type: Not defined
- Accept: application/json
Back to top | Back to API list | Back to README
Get the current token
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)
}This endpoint does not need any parameter.
Other parameters are passed through a pointer to a apiGetTokenCurrentRequest struct via the builder pattern
- Content-Type: Not defined
- Accept: application/json
Back to top | Back to API list | Back to README
List tokens for a customer
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)
}| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
| customerId | string | Alphanumeric string identifying the customer. |
Other parameters are passed through a pointer to a apiListTokensCustomerRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|
- Content-Type: Not defined
- Accept: application/json
Back to top | Back to API list | Back to README
List tokens for the authenticated user
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)
}This endpoint does not need any parameter.
Other parameters are passed through a pointer to a apiListTokensUserRequest struct via the builder pattern
- Content-Type: Not defined
- Accept: application/json
Back to top | Back to API list | Back to README
Revoke a token
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)
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
| tokenId | string | Alphanumeric string identifying a token. |
Other parameters are passed through a pointer to a apiRevokeTokenRequest struct via the builder pattern
| Name | Type | Description | Notes |
|---|
(empty response body)
- Content-Type: Not defined
- Accept: application/json
Back to top | Back to API list | Back to README
Revoke the current token
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)
}
}This endpoint does not need any parameter.
Other parameters are passed through a pointer to a apiRevokeTokenCurrentRequest struct via the builder pattern
(empty response body)
- Content-Type: Not defined
- Accept: application/json