Skip to content

Latest commit

 

History

History
255 lines (194 loc) · 9.14 KB

README.md

File metadata and controls

255 lines (194 loc) · 9.14 KB

SecretManagement

(SecretManagement)

Overview

Requires that the secret-management plugin is installed on the server.

Manage secrets variables.

Available Operations

GetAllSecrets

Get the list of all secrets without their value

Example Usage

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
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.

Response

*operations.GetAllSecretsResponse, error

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

UpdateSecret

Update a secret and override the value, the name cannot be overridden

Example Usage

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
    }
}

Parameters

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.

Response

*operations.UpdateSecretResponse, error

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

AddSecret

Add a secret

Example Usage

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
    }
}

Parameters

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.

Response

*operations.AddSecretResponse, error

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

GetSecret

Get one secret by its unique name

Example Usage

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
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
name string ✔️ Unique name of the secret

Response

*operations.GetSecretResponse, error

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

DeleteSecret

Remove the secret by its unique name

Example Usage

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
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
name string ✔️ Unique name of the secret

Response

*operations.DeleteSecretResponse, error

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /