Skip to content

Latest commit

 

History

History
265 lines (191 loc) · 11.2 KB

README.md

File metadata and controls

265 lines (191 loc) · 11.2 KB

AccessControl

(AccessControl)

Overview

Operations related to access control/signing keys api

Available Operations

  • Create - Create a signing key
  • GetAll - Retrieves signing keys
  • Delete - Delete Signing Key
  • Get - Retrieves a signing key
  • Update - Update a signing key

Create

The publicKey is a representation of the public key, encoded as base 64 and is passed as a string, and the privateKey is displayed only on creation. This is the only moment where the client can save the private key, otherwise it will be lost. Remember to decode your string when signing JWTs. Up to 10 signing keys can be generated, after that you must delete at least one signing key to create a new one.

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.AccessControl.Create(ctx)
    if err != nil {
        log.Fatal(err)
    }
    if res.SigningKey != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CreateSigningKeyResponse, error

Errors

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

GetAll

Retrieves signing keys

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.AccessControl.GetAll(ctx)
    if err != nil {
        log.Fatal(err)
    }
    if res.Data != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
opts []operations.Option The options for this request.

Response

*operations.GetSigningKeysResponse, error

Errors

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

Delete

Delete Signing Key

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.AccessControl.Delete(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
keyID string ✔️ ID of the signing key
opts []operations.Option The options for this request.

Response

*operations.DeleteSigningKeyResponse, error

Errors

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

Get

Retrieves a signing key

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.AccessControl.Get(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.SigningKey != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
keyID string ✔️ ID of the signing key
opts []operations.Option The options for this request.

Response

*operations.GetSigningKeyResponse, error

Errors

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

Update

Update a signing key

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"github.com/livepeer/livepeer-go/models/operations"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.AccessControl.Update(ctx, "<value>", operations.UpdateSigningKeyRequestBody{})
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
keyID string ✔️ ID of the signing key
requestBody operations.UpdateSigningKeyRequestBody ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.UpdateSigningKeyResponse, error

Errors

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