Skip to content

Latest commit

 

History

History
136 lines (109 loc) · 7.32 KB

README.md

File metadata and controls

136 lines (109 loc) · 7.32 KB

Ratelimits

(Ratelimits)

Overview

Available Operations

Limit

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.Ratelimits.Limit(ctx, operations.LimitRequestBody{
        Namespace: unkeygo.String("email.outbound"),
        Identifier: "user_123",
        Limit: 10,
        Duration: 60000,
        Cost: unkeygo.Int64(2),
        Resources: []operations.Resources{
            operations.Resources{
                Type: "organization",
                ID: "org_123",
                Name: unkeygo.String("unkey"),
            },
        },
    })
    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.LimitRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.LimitResponse, 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 */*

DeleteOverride

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.Ratelimits.DeleteOverride(ctx, operations.DeleteOverrideRequestBody{
        NamespaceID: unkeygo.String("rlns_1234"),
        NamespaceName: unkeygo.String("email.outbound"),
        Identifier: "user_123",
    })
    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.DeleteOverrideRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.DeleteOverrideResponse, 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 */*