Skip to content

Latest commit

 

History

History
324 lines (258 loc) · 18.5 KB

README.md

File metadata and controls

324 lines (258 loc) · 18.5 KB

Identities

(Identities)

Available Operations

CreateIdentity

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.CreateIdentityRequestBody{
        ExternalID: "user_123",
        Ratelimits: []operations.Ratelimits{
            operations.Ratelimits{
                Name: "tokens",
                Limit: 10,
                Duration: 1000,
            },
        },
    }
    ctx := context.Background()
    res, err := s.Identities.CreateIdentity(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.CreateIdentityRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

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

GetIdentity

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.GetIdentityRequest{
        IdentityID: unkeygo.String("id_1234"),
        ExternalID: unkeygo.String("id_1234"),
    }
    ctx := context.Background()
    res, err := s.Identities.GetIdentity(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.GetIdentityRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

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

ListIdentities

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.ListIdentitiesRequest{
        Limit: unkeygo.Int64(100),
    }
    ctx := context.Background()
    res, err := s.Identities.ListIdentities(ctx, request)
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
                for {
            // handle items
        
            res, err = res.Next()
        
            if err != nil {
                // handle error
            }
        
            if res == nil {
                break
            }
        }
        
    }
}

Parameters

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

Response

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

UpdateIdentity

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.UpdateIdentityRequestBody{
        IdentityID: unkeygo.String("id_1234"),
        ExternalID: unkeygo.String("user_1234"),
        Ratelimits: []operations.UpdateIdentityRatelimits{
            operations.UpdateIdentityRatelimits{
                Name: "tokens",
                Limit: 10,
                Duration: 1000,
            },
        },
    }
    ctx := context.Background()
    res, err := s.Identities.UpdateIdentity(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.UpdateIdentityRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

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

DeleteIdentity

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.DeleteIdentityRequestBody{
        IdentityID: "id_1234",
    }
    ctx := context.Background()
    res, err := s.Identities.DeleteIdentity(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.DeleteIdentityRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

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