Skip to content

Latest commit

 

History

History
221 lines (165 loc) · 10.3 KB

README.md

File metadata and controls

221 lines (165 loc) · 10.3 KB

Auth

(Auth)

Overview

REST APIs for managing Authentication

Available Operations

  • GetAccess - Get access allowances for a particular workspace
  • GetAccessToken - Get or refresh an access token for the current workspace.
  • GetUser - Get information about the current user.
  • ValidateAPIKey - Validate the current api key.

GetAccess

Checks if generation is permitted for a particular run of the CLI

Example Usage

package main

import(
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"context"
	"log"
)

func main() {
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Auth.GetAccess(ctx, operations.GetWorkspaceAccessRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.AccessDetails != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.GetWorkspaceAccessResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.SDKError 4XX, 5XX */*

GetAccessToken

Get or refresh an access token for the current workspace.

Example Usage

package main

import(
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"context"
	"log"
)

func main() {
    s := speakeasyclientsdkgo.New()

    ctx := context.Background()
    res, err := s.Auth.GetAccessToken(ctx, operations.GetAccessTokenRequest{
        WorkspaceID: "<value>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.AccessToken != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.GetAccessTokenResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.Error 4XX application/json
sdkerrors.SDKError 5XX */*

GetUser

Get information about the current user.

Example Usage

package main

import(
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"context"
	"log"
)

func main() {
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Auth.GetUser(ctx)
    if err != nil {
        log.Fatal(err)
    }
    if res.User != 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.GetUserResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.Error 4XX application/json
sdkerrors.SDKError 5XX */*

ValidateAPIKey

Validate the current api key.

Example Usage

package main

import(
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"context"
	"log"
)

func main() {
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    ctx := context.Background()
    res, err := s.Auth.ValidateAPIKey(ctx)
    if err != nil {
        log.Fatal(err)
    }
    if res.APIKeyDetails != 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.ValidateAPIKeyResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.Error 4XX application/json
sdkerrors.SDKError 5XX */*