Skip to content

Latest commit

 

History

History
348 lines (277 loc) · 19 KB

README.md

File metadata and controls

348 lines (277 loc) · 19 KB

Identities

(Identities)

Overview

Available Operations

CreateIdentity

Example Usage

package main

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

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

    res, err := s.Identities.CreateIdentity(ctx, operations.CreateIdentityRequestBody{
        ExternalID: "user_123",
        Ratelimits: []operations.Ratelimits{
            operations.Ratelimits{
                Name: "tokens",
                Limit: 10,
                Duration: 1000,
            },
            operations.Ratelimits{
                Name: "tokens",
                Limit: 10,
                Duration: 1000,
            },
            operations.Ratelimits{
                Name: "tokens",
                Limit: 10,
                Duration: 1000,
            },
        },
    })
    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

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 */*

GetIdentity

Example Usage

package main

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

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

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

Response

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

ListIdentities

Example Usage

package main

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

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

    res, err := s.Identities.ListIdentities(ctx, operations.ListIdentitiesRequest{})
    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

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 */*

UpdateIdentity

Example Usage

package main

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

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

    res, err := s.Identities.UpdateIdentity(ctx, operations.UpdateIdentityRequestBody{
        IdentityID: unkeygo.String("id_1234"),
        ExternalID: unkeygo.String("user_1234"),
        Ratelimits: []operations.UpdateIdentityRatelimits{
            operations.UpdateIdentityRatelimits{
                Name: "tokens",
                Limit: 10,
                Duration: 1000,
            },
            operations.UpdateIdentityRatelimits{
                Name: "tokens",
                Limit: 10,
                Duration: 1000,
            },
            operations.UpdateIdentityRatelimits{
                Name: "tokens",
                Limit: 10,
                Duration: 1000,
            },
        },
    })
    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

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 */*

DeleteIdentity

Example Usage

package main

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

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

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

Response

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