Skip to content

Latest commit

 

History

History
74 lines (60 loc) · 3.61 KB

README.md

File metadata and controls

74 lines (60 loc) · 3.61 KB

Ratelimits

(Ratelimits)

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

Response

*operations.LimitResponse, error

Error Object 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 /