AdminSessionsApi

Method

HTTP request

Description

get_admin_sessions_stats

GET /admin/sessions/stats

Get session inventory stats

list_admin_sessions

GET /admin/sessions

List live sessions

revoke_admin_session

DELETE /admin/sessions/{session-id}

Revoke a session

get_admin_sessions_stats

AdminSessionsStatsResponse get_admin_sessions_stats()

Get session inventory stats

Returns aggregate counters across all live sessions (total, by transport, anonymous count, Azure exchange-cache count). Result is cached per-process for ~30 seconds; the cache_age_seconds field communicates freshness so a polling dashboard can render it.

Example

  • Bearer Authentication (bearerAuth):

import h2ogpte.rest_async
from h2ogpte.rest_async.models.admin_sessions_stats_response import AdminSessionsStatsResponse
from h2ogpte.rest_async.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_async.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_async.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
async with h2ogpte.rest_async.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = h2ogpte.rest_async.AdminSessionsApi(api_client)

    try:
        # Get session inventory stats
        api_response = await api_instance.get_admin_sessions_stats()
        print("The response of AdminSessionsApi->get_admin_sessions_stats:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling AdminSessionsApi->get_admin_sessions_stats: %s\n" % e)

Parameters

This endpoint does not need any parameter.

Return type

AdminSessionsStatsResponse

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

-

403

Caller is not an admin.

-

500

Internal server error

-

list_admin_sessions

AdminSessionsListResponse list_admin_sessions(cursor=cursor, limit=limit)

List live sessions

Allows admins to enumerate live sessions stored in Redis. Returns metadata only — never access tokens, refresh tokens, or CSRF values. Pagination is cursor-based; pass back the next_cursor from a previous response to continue, or omit to start fresh. Iteration is complete when next_cursor is absent.

Example

  • Bearer Authentication (bearerAuth):

import h2ogpte.rest_async
from h2ogpte.rest_async.models.admin_sessions_list_response import AdminSessionsListResponse
from h2ogpte.rest_async.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_async.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_async.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
async with h2ogpte.rest_async.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = h2ogpte.rest_async.AdminSessionsApi(api_client)
    cursor = 'cursor_example' # str | Opaque cursor returned by a previous call. Omit on the first call. (optional)
    limit = 100 # int | Maximum number of sessions to return in this page. Defaults to 100, hard-capped at 500. (optional) (default to 100)

    try:
        # List live sessions
        api_response = await api_instance.list_admin_sessions(cursor=cursor, limit=limit)
        print("The response of AdminSessionsApi->list_admin_sessions:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling AdminSessionsApi->list_admin_sessions: %s\n" % e)

Parameters

Name

Type

Description

Notes

cursor

str

Opaque cursor returned by a previous call. Omit on the first call.

[optional]

limit

int

Maximum number of sessions to return in this page. Defaults to 100, hard-capped at 500.

[optional] [default to 100]

Return type

AdminSessionsListResponse

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

-

403

Caller is not an admin.

-

500

Internal server error

-

revoke_admin_session

revoke_admin_session(session_id)

Revoke a session

Force-revokes a live session by ID. Reuses the same revoke path as user-driven sign-out, so peer mux replicas drop their cached copy via pub/sub. DELETE is idempotent — returns 204 whether the session existed or not.

Example

  • Bearer Authentication (bearerAuth):

import h2ogpte.rest_async
from h2ogpte.rest_async.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_async.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_async.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
async with h2ogpte.rest_async.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = h2ogpte.rest_async.AdminSessionsApi(api_client)
    session_id = 'session_id_example' # str | ID of the session to revoke.

    try:
        # Revoke a session
        await api_instance.revoke_admin_session(session_id)
    except Exception as e:
        print("Exception when calling AdminSessionsApi->revoke_admin_session: %s\n" % e)

Parameters

Name

Type

Description

Notes

session_id

str

ID of the session to revoke.

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

-

403

Caller is not an admin.

-

500

Internal server error

-