Rotates an API key and returns a new token. All previous tokens for this key are invalidated.
Rotate an API key
package main
import (
"context"
"fmt"
"github.com/cadenya/cadenya-go"
"github.com/cadenya/cadenya-go/option"
)
func main() {
client := cadenya.NewClient(
option.WithAPIKey("My API Key"),
)
apiKey, err := client.APIKeys.Rotate(context.TODO(), "id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", apiKey.Metadata)
}
{
"metadata": {
"id": "id",
"accountId": "accountId",
"name": "name",
"profileId": "profileId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"token": "token",
"description": "description",
"permissions": [
"string"
],
"system": true
},
"info": {
"createdBy": {
"metadata": {
"id": "id",
"accountId": "accountId",
"name": "name",
"profileId": "profileId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"type": "PROFILE_TYPE_UNSPECIFIED",
"email": "email",
"name": "name"
}
},
"workspacesPreview": [
{
"id": "id",
"name": "name"
}
],
"workspacesTotal": 0
}
}Returns Examples
{
"metadata": {
"id": "id",
"accountId": "accountId",
"name": "name",
"profileId": "profileId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"token": "token",
"description": "description",
"permissions": [
"string"
],
"system": true
},
"info": {
"createdBy": {
"metadata": {
"id": "id",
"accountId": "accountId",
"name": "name",
"profileId": "profileId",
"externalId": "externalId",
"labels": {
"foo": "string"
}
},
"spec": {
"type": "PROFILE_TYPE_UNSPECIFIED",
"email": "email",
"name": "name"
}
},
"workspacesPreview": [
{
"id": "id",
"name": "name"
}
],
"workspacesTotal": 0
}
}