(SecretManagement)
Requires that the secret-management
plugin is installed on the server.
Manage secrets variables.
- GetAllSecrets - List all secrets
- UpdateSecret - Update a secret
- AddSecret - Create a secret
- GetSecret - Get one secret
- DeleteSecret - Delete a secret
Get the list of all secrets without their value
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
ctx := context.Background()
res, err := s.SecretManagement.GetAllSecrets(ctx)
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. |
*operations.GetAllSecretsResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Update a secret and override the value, the name cannot be overridden
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"github.com/infra-rdc/rudder-go/models/components"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
request := components.Secrets{
Name: rudder.String("secret-password"),
Description: rudder.String("Password of my super secret user account"),
Value: rudder.String("nj-k;EO32!kFWewn2Nk,u"),
}
ctx := context.Background()
res, err := s.SecretManagement.UpdateSecret(ctx, request)
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.Secrets | ✔️ | The request object to use for the request. |
*operations.UpdateSecretResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Add a secret
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"github.com/infra-rdc/rudder-go/models/components"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
request := components.Secrets{
Name: rudder.String("secret-password"),
Description: rudder.String("Password of my super secret user account"),
Value: rudder.String("nj-k;EO32!kFWewn2Nk,u"),
}
ctx := context.Background()
res, err := s.SecretManagement.AddSecret(ctx, request)
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.Secrets | ✔️ | The request object to use for the request. |
*operations.AddSecretResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Get one secret by its unique name
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var name string = "<value>"
ctx := context.Background()
res, err := s.SecretManagement.GetSecret(ctx, name)
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. |
name |
string | ✔️ | Unique name of the secret |
*operations.GetSecretResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Remove the secret by its unique name
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var name string = "<value>"
ctx := context.Background()
res, err := s.SecretManagement.DeleteSecret(ctx, name)
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. |
name |
string | ✔️ | Unique name of the secret |
*operations.DeleteSecretResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |