(Tokens)
- CreateToken - Create ingestion token
Create ingestion token
package main
import(
"os"
swosdkgo "github.com/solarwinds/swo-sdk-go"
"github.com/solarwinds/swo-sdk-go/models/components"
"context"
"log"
)
func main() {
s := swosdkgo.New(
swosdkgo.WithSecurity(os.Getenv("SWO_API_TOKEN")),
)
ctx := context.Background()
res, err := s.Tokens.CreateToken(ctx, components.CreateTokenRequest{
Name: "<value>",
Tags: components.Tags{
Server: "<value>",
TagWithoutValue: "<value>",
},
Type: components.TypeIngestion,
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.CreateTokenRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CreateTokenResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.APIError | 4XX, 5XX | */* |