APIKeysApi

Method

HTTP request

Description

create_api_key_for_user

POST /admin/api-keys

Create an API key

deactivate_api_key

POST /admin/api-keys/deactivate/{key-id}

Deactivate an API key

delete_api_key

DELETE /admin/api-keys/{key-id}

Delete an API key.

list_all_api_keys

GET /admin/api-keys

List API keys.

update_api_key_expiry

PATCH /admin/api-keys/expire/{key-id}

Update API key expiry.

create_api_key_for_user

APIKeyResult create_api_key_for_user(api_key_create_request)

Create an API key

Allows admins to create an API key for another user.

Example

  • Bearer Authentication (bearerAuth):

import h2ogpte.rest
from h2ogpte.rest.models.api_key_create_request import APIKeyCreateRequest
from h2ogpte.rest.models.api_key_result import APIKeyResult
from h2ogpte.rest.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte.rest.Configuration(
    host = "https://h2ogpte.genai.h2o.ai/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearerAuth
configuration = h2ogpte.rest.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
async with h2ogpte.rest.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = h2ogpte.rest.APIKeysApi(api_client)
    api_key_create_request = h2ogpte.rest.APIKeyCreateRequest() # APIKeyCreateRequest | 

    try:
        # Create an API key
        api_response = await api_instance.create_api_key_for_user(api_key_create_request)
        print("The response of APIKeysApi->create_api_key_for_user:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling APIKeysApi->create_api_key_for_user: %s\n" % e)

Parameters

Name

Type

Description

Notes

api_key_create_request

APIKeyCreateRequest

Return type

APIKeyResult

HTTP request headers

  • Content-Type: application/json

  • Accept: application/json

HTTP response details

Status code

Description

Response headers

201

Successful operation

-

401

Unauthorized - Invalid or missing API key

-

500

Internal server error

-

deactivate_api_key

deactivate_api_key(key_id)

Deactivate an API key

Allows admins to deactivate an API key.

Example

  • Bearer Authentication (bearerAuth):

import h2ogpte.rest
from h2ogpte.rest.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte.rest.Configuration(
    host = "https://h2ogpte.genai.h2o.ai/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearerAuth
configuration = h2ogpte.rest.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
async with h2ogpte.rest.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = h2ogpte.rest.APIKeysApi(api_client)
    key_id = 'key_id_example' # str | Id of the key to deactivate.

    try:
        # Deactivate an API key
        await api_instance.deactivate_api_key(key_id)
    except Exception as e:
        print("Exception when calling APIKeysApi->deactivate_api_key: %s\n" % e)

Parameters

Name

Type

Description

Notes

key_id

str

Id of the key to deactivate.

Return type

void (empty response body)

HTTP request headers

  • Content-Type: Not defined

  • Accept: application/json

HTTP response details

Status code

Description

Response headers

204

Successful operation

-

401

Unauthorized - Invalid or missing API key

-

delete_api_key

delete_api_key(key_id)

Delete an API key.

Allows admins to delete an API key.

Example

  • Bearer Authentication (bearerAuth):

import h2ogpte.rest
from h2ogpte.rest.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte.rest.Configuration(
    host = "https://h2ogpte.genai.h2o.ai/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearerAuth
configuration = h2ogpte.rest.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
async with h2ogpte.rest.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = h2ogpte.rest.APIKeysApi(api_client)
    key_id = 'key_id_example' # str | Id of the key to delete.

    try:
        # Delete an API key.
        await api_instance.delete_api_key(key_id)
    except Exception as e:
        print("Exception when calling APIKeysApi->delete_api_key: %s\n" % e)

Parameters

Name

Type

Description

Notes

key_id

str

Id of the key to delete.

Return type

void (empty response body)

HTTP request headers

  • Content-Type: Not defined

  • Accept: application/json

HTTP response details

Status code

Description

Response headers

204

Successful operation

-

401

Unauthorized - Invalid or missing API key

-

list_all_api_keys

List[APIKeyInfo] list_all_api_keys(offset=offset, limit=limit, filter=filter)

List API keys.

Allows admins to list all existing API keys.

Example

  • Bearer Authentication (bearerAuth):

import h2ogpte.rest
from h2ogpte.rest.models.api_key_info import APIKeyInfo
from h2ogpte.rest.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte.rest.Configuration(
    host = "https://h2ogpte.genai.h2o.ai/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearerAuth
configuration = h2ogpte.rest.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
async with h2ogpte.rest.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = h2ogpte.rest.APIKeysApi(api_client)
    offset = 0 # int | How many API keys to skip before returning. (optional) (default to 0)
    limit = 100 # int | How many API keys to return. (optional) (default to 100)
    filter = 'filter_example' # str | Only returns keys for usernames matching this filter. (optional)

    try:
        # List API keys.
        api_response = await api_instance.list_all_api_keys(offset=offset, limit=limit, filter=filter)
        print("The response of APIKeysApi->list_all_api_keys:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling APIKeysApi->list_all_api_keys: %s\n" % e)

Parameters

Name

Type

Description

Notes

offset

int

How many API keys to skip before returning.

[optional] [default to 0]

limit

int

How many API keys to return.

[optional] [default to 100]

filter

str

Only returns keys for usernames matching this filter.

[optional]

Return type

List[APIKeyInfo]

HTTP request headers

  • Content-Type: Not defined

  • Accept: application/json

HTTP response details

Status code

Description

Response headers

200

Successful operation

-

401

Unauthorized - Invalid or missing API key

-

update_api_key_expiry

update_api_key_expiry(key_id, api_key_update_expiry_request=api_key_update_expiry_request)

Update API key expiry.

Allows admins to update the expiration of an API key (either set a new expiry or remove one).

Example

  • Bearer Authentication (bearerAuth):

import h2ogpte.rest
from h2ogpte.rest.models.api_key_update_expiry_request import APIKeyUpdateExpiryRequest
from h2ogpte.rest.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://h2ogpte.genai.h2o.ai/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = h2ogpte.rest.Configuration(
    host = "https://h2ogpte.genai.h2o.ai/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: bearerAuth
configuration = h2ogpte.rest.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
async with h2ogpte.rest.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = h2ogpte.rest.APIKeysApi(api_client)
    key_id = 'key_id_example' # str | Id of the key to update.
    api_key_update_expiry_request = h2ogpte.rest.APIKeyUpdateExpiryRequest() # APIKeyUpdateExpiryRequest |  (optional)

    try:
        # Update API key expiry.
        await api_instance.update_api_key_expiry(key_id, api_key_update_expiry_request=api_key_update_expiry_request)
    except Exception as e:
        print("Exception when calling APIKeysApi->update_api_key_expiry: %s\n" % e)

Parameters

Name

Type

Description

Notes

key_id

str

Id of the key to update.

api_key_update_expiry_request

APIKeyUpdateExpiryRequest

[optional]

Return type

void (empty response body)

HTTP request headers

  • Content-Type: application/json

  • Accept: application/json

HTTP response details

Status code

Description

Response headers

204

Successful operation

-

401

Unauthorized - Invalid or missing API key

-