Skip to content

Latest commit

 

History

History
787 lines (616 loc) · 39.8 KB

README.md

File metadata and controls

787 lines (616 loc) · 39.8 KB

Keys

(keys)

Overview

Available Operations

get

Example Usage

from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.get(key_id="key_1234")

    if res.key is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description Example
key_id str ✔️ N/A key_1234
decrypt OptionalNullable[bool] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetKeyResponse

Errors

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

whoami

Example Usage

from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.whoami(request={
        "key": "sk_123",
    })

    if res.object is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.WhoamiRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WhoamiResponse

Errors

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

delete

Example Usage

from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.delete(request={
        "key_id": "key_1234",
    })

    if res.object is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.DeleteKeyRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.DeleteKeyResponse

Errors

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

create

Example Usage

import unkey_py
from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.create(request={
        "api_id": "api_123",
        "name": "my key",
        "external_id": "team_123",
        "meta": {
            "billingTier": "PRO",
            "trialEnds": "2023-06-16T17:16:37.161Z",
        },
        "roles": [
            "admin",
            "finance",
        ],
        "permissions": [
            "domains.create_record",
            "say_hello",
        ],
        "expires": 1623869797161,
        "remaining": 1000,
        "refill": {
            "interval": unkey_py.CreateKeyInterval.MONTHLY,
            "amount": 100,
            "refill_day": 15,
        },
        "ratelimit": {
            "limit": 10,
            "type": unkey_py.CreateKeyType.FAST,
            "duration": 60000,
        },
        "enabled": False,
    })

    if res.object is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.CreateKeyRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CreateKeyResponse

Errors

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

verify

Example Usage

from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.verify(request={
        "key": "sk_1234",
        "api_id": "api_1234",
        "ratelimits": [
            {
                "name": "tokens",
                "limit": 500,
                "duration": 3600000,
            },
            {
                "name": "tokens",
                "limit": 20000,
                "duration": 86400000,
            },
        ],
    })

    if res.v1_keys_verify_key_response is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.V1KeysVerifyKeyRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VerifyKeyResponse

Errors

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

update

Example Usage

import unkey_py
from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.update(request={
        "key_id": "key_123",
        "name": "Customer X",
        "external_id": "user_123",
        "meta": {
            "roles": [
                "admin",
                "user",
            ],
            "stripeCustomerId": "cus_1234",
        },
        "expires": 0,
        "ratelimit": {
            "limit": 10,
            "type": unkey_py.UpdateKeyType.FAST,
            "refill_rate": 1,
            "refill_interval": 60,
        },
        "remaining": 1000,
        "refill": {
            "interval": unkey_py.UpdateKeyInterval.DAILY,
            "amount": 100,
        },
        "enabled": True,
        "roles": [
            {
                "id": "perm_123",
            },
            {
                "name": "dns.record.create",
            },
            {
                "name": "dns.record.delete",
                "create": True,
            },
        ],
        "permissions": [
            {
                "id": "perm_123",
            },
            {
                "name": "dns.record.create",
            },
            {
                "name": "dns.record.delete",
                "create": True,
            },
        ],
    })

    if res.object is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.UpdateKeyRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.UpdateKeyResponse

Errors

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

update_remaining

Example Usage

import unkey_py
from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.update_remaining(request={
        "key_id": "key_123",
        "op": unkey_py.Op.SET,
        "value": 1,
    })

    if res.object is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.UpdateRemainingRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.UpdateRemainingResponse

Errors

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

get_verifications

Example Usage

import unkey_py
from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.get_verifications(request={
        "key_id": "key_1234",
        "owner_id": "chronark",
        "start": 1620000000000,
        "end": 1620000000000,
        "granularity": unkey_py.Granularity.DAY,
    })

    if res.object is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.GetVerificationsRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetVerificationsResponse

Errors

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

add_permissions

Example Usage

from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.add_permissions(request={
        "key_id": "<id>",
        "permissions": [
            {},
        ],
    })

    if res.response_bodies is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.AddPermissionsRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.AddPermissionsResponse

Errors

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

remove_permissions

Example Usage

from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.remove_permissions(request={
        "key_id": "<id>",
        "permissions": [
            {
                "id": "perm_123",
            },
            {
                "name": "dns.record.create",
            },
        ],
    })

    if res.object is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.RemovePermissionsRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.RemovePermissionsResponse

Errors

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

set_permissions

Example Usage

from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.set_permissions(request={
        "key_id": "<id>",
        "permissions": [
            {
                "id": "perm_123",
            },
            {
                "name": "dns.record.create",
            },
            {
                "name": "dns.record.delete",
                "create": True,
            },
        ],
    })

    if res.response_bodies is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.SetPermissionsRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.SetPermissionsResponse

Errors

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

add_roles

Example Usage

from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.add_roles(request={
        "key_id": "<id>",
        "roles": [
            {
                "id": "role_123",
            },
            {
                "name": "dns.record.create",
            },
            {
                "name": "dns.record.delete",
                "create": True,
            },
        ],
    })

    if res.response_bodies is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.AddRolesRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.AddRolesResponse

Errors

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

remove_roles

Example Usage

from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.remove_roles(request={
        "key_id": "<id>",
        "roles": [
            {
                "id": "role_123",
            },
            {
                "name": "dns.record.create",
            },
        ],
    })

    if res.object is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.RemoveRolesRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.RemoveRolesResponse

Errors

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

set_roles

Example Usage

from unkey_py import Unkey

with Unkey(
    bearer_auth="UNKEY_ROOT_KEY",
) as s:
    res = s.keys.set_roles(request={
        "key_id": "<id>",
        "roles": [
            {
                "id": "role_123",
            },
            {
                "name": "dns.record.create",
            },
            {
                "name": "dns.record.delete",
                "create": True,
            },
        ],
    })

    if res.response_bodies is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.SetRolesRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.SetRolesResponse

Errors

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