Skip to content

Latest commit

 

History

History
298 lines (235 loc) · 16.5 KB

README.md

File metadata and controls

298 lines (235 loc) · 16.5 KB

Apis

(Apis)

Overview

Available Operations

GetAPI

Example Usage

package main

import(
	unkeygo "github.com/unkeyed/unkey-go"
	"github.com/unkeyed/unkey-go/models/operations"
	"context"
	"log"
)

func main() {
    s := unkeygo.New(
        unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
    )

    ctx := context.Background()
    res, err := s.Apis.GetAPI(ctx, operations.GetAPIRequest{
        APIID: "api_1234",
    })
    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 operations.GetAPIRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.GetAPIResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.ErrBadRequest 400 application/json
sdkerrors.ErrUnauthorized 401 application/json
sdkerrors.ErrForbidden 403 application/json
sdkerrors.ErrNotFound 404 application/json
sdkerrors.ErrConflict 409 application/json
sdkerrors.ErrTooManyRequests 429 application/json
sdkerrors.ErrInternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

CreateAPI

Example Usage

package main

import(
	unkeygo "github.com/unkeyed/unkey-go"
	"github.com/unkeyed/unkey-go/models/operations"
	"context"
	"log"
)

func main() {
    s := unkeygo.New(
        unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
    )

    ctx := context.Background()
    res, err := s.Apis.CreateAPI(ctx, operations.CreateAPIRequestBody{
        Name: "my-api",
    })
    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 operations.CreateAPIRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CreateAPIResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.ErrBadRequest 400 application/json
sdkerrors.ErrUnauthorized 401 application/json
sdkerrors.ErrForbidden 403 application/json
sdkerrors.ErrNotFound 404 application/json
sdkerrors.ErrConflict 409 application/json
sdkerrors.ErrTooManyRequests 429 application/json
sdkerrors.ErrInternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

ListKeys

Example Usage

package main

import(
	unkeygo "github.com/unkeyed/unkey-go"
	"github.com/unkeyed/unkey-go/models/operations"
	"context"
	"log"
)

func main() {
    s := unkeygo.New(
        unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
    )

    ctx := context.Background()
    res, err := s.Apis.ListKeys(ctx, operations.ListKeysRequest{
        APIID: "api_1234",
        Limit: unkeygo.Int64(100),
    })
    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 operations.ListKeysRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.ListKeysResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.ErrBadRequest 400 application/json
sdkerrors.ErrUnauthorized 401 application/json
sdkerrors.ErrForbidden 403 application/json
sdkerrors.ErrNotFound 404 application/json
sdkerrors.ErrConflict 409 application/json
sdkerrors.ErrTooManyRequests 429 application/json
sdkerrors.ErrInternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

DeleteAPI

Example Usage

package main

import(
	unkeygo "github.com/unkeyed/unkey-go"
	"github.com/unkeyed/unkey-go/models/operations"
	"context"
	"log"
)

func main() {
    s := unkeygo.New(
        unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
    )

    ctx := context.Background()
    res, err := s.Apis.DeleteAPI(ctx, operations.DeleteAPIRequestBody{
        APIID: "api_1234",
    })
    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 operations.DeleteAPIRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.DeleteAPIResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.ErrBadRequest 400 application/json
sdkerrors.ErrUnauthorized 401 application/json
sdkerrors.ErrForbidden 403 application/json
sdkerrors.ErrNotFound 404 application/json
sdkerrors.ErrConflict 409 application/json
sdkerrors.ErrDeleteProtected 429 application/json
sdkerrors.ErrInternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

DeleteKeys

Example Usage

package main

import(
	unkeygo "github.com/unkeyed/unkey-go"
	"github.com/unkeyed/unkey-go/models/operations"
	"context"
	"log"
)

func main() {
    s := unkeygo.New(
        unkeygo.WithSecurity("UNKEY_ROOT_KEY"),
    )

    ctx := context.Background()
    res, err := s.Apis.DeleteKeys(ctx, operations.DeleteKeysRequestBody{
        APIID: "api_1234",
    })
    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 operations.DeleteKeysRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.DeleteKeysResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.ErrBadRequest 400 application/json
sdkerrors.ErrUnauthorized 401 application/json
sdkerrors.ErrForbidden 403 application/json
sdkerrors.ErrNotFound 404 application/json
sdkerrors.ErrConflict 409 application/json
sdkerrors.ErrTooManyRequests 429 application/json
sdkerrors.ErrInternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*