Showing content from https://github.com/rockset/rockset-python-client below:
GitHub - rockset/rockset-python-client: Rockset python client
(These are the docs for Rockset's v1 Python client. Looking for the v0 docs?)
Rockset's Python SDK allows for creating and managing resources in Rockset. Each supported endpoint is documented below.
This Python package is automatically generated by the OpenAPI Generator project.
Python >=3.6
Then import the package:
Please follow the installation procedure and then run the following:
import rockset
# Defining the host is optional and defaults to *https://api.use1a1.rockset.com*
rs = rockset.RocksetClient(host=rockset.Regions.use1a1, api_key="APIKEY")
try:
rs.APIKeys.create(name="api-key-name", role="member")
except rockset.ApiException as e:
print("Exception when calling ApiKey->create_api_key: %s\n" % e)
Note: If you receive SSL Errors while using the client, this could be caused by your python installation. One possible fix is running the following commands:
CERT_PATH=$(python3 -m certifi)
export SSL_CERT_FILE=${CERT_PATH}
export REQUESTS_CA_BUNDLE=${CERT_PATH}
As a last resort, you can configure the client to avoid certificate verification. Note that you will receive warnings from urllib3 when requests are made.
from rockset import RocksetClient, Regions, Configuration
config = Configuration(api_key=KEY)
config.verify_ssl = False
rs = RocksetClient(host=Regions.rs2, config=config)
When making requests, certain parameters will oftentimes be instances of classes (eg. rockset.models.QueryRequestSql). Since importing and instantiating these objects can be verbose, you always have the option of passing in a dictionary instead of a model.
Queries can be made be either calling the regular client query method or by using the convenience method (rs.sql). The convenience method currently does not support all the options of the regular call. If you need these more advanced features, you should use the regular call.
from rockset import RocksetClient
rs = RocksetClient(api_key=APIKEY)
try:
res = rs.Queries.query(
async_options={
"client_timeout_ms": 1,
"max_initial_results": 1,
"timeout_ms": 1,
},
sql={
"query": "SELECT * FROM foo where _id = :_id",
},
)
except rockset.ApiException as e:
print("Exception when querying: %s\n" % e)
import rockset
rs = rockset.RocksetClient(host=rockset.Regions.use1a1, api_key="APIKEY")
try:
res = rs.sql(query="SELECT * FROM _events WHERE kind=:event_type LIMIT 100", params={"event_type", "INGEST"})
except rockset.ApiException as e:
print("Exception when querying: %s\n" % e)
Query pagination can be achieved by using the normal API call (rs.Queries.get_query_results()) or by using the QueryPaginator class as an iterator. The QueryPaginator should be initialized by passing in a client object and a QueryResponse object. The QueryResponse object could be the result of any call that returns this object (query, get_query, execute_query_lambda, execute_query_lambda_by_tag). You will then be able to use the QueryPaginator object like you would any other iterator.
import rockset
rs = rockset.RocksetClient(host=rockset.Regions.use1a1, api_key="APIKEY")
for page in rockset.QueryPaginator(
rs,
rs.Queries.query(
sql=rockset.models.QueryRequestSql(
query="SELECT * FROM _events LIMIT 500",
paginate=True,
initial_paginate_response_doc_count=100,
)
),
):
print(page)
Migration to the new client should generally be a simple process. The most important thing to note is that the query builder has been deprecated and is not included in this client.
Most of the other differences between this client and the older version are small:
- The main client class is called 'RocksetClient' rather than 'Client'
- The parameter which is used to specify the apiserver location is 'host' rather than 'api_server'
- Some of the endpoints and their parameters have been renamed (see documentation for each endpoint)
Documentation for API Endpoints Class Method HTTP request Description APIKeys create POST /v1/orgs/self/users/self/apikeys Create API Key APIKeys delete DELETE /v1/orgs/self/users/{user}/apikeys/{name} Delete API Key APIKeys get GET /v1/orgs/self/users/{user}/apikeys/{name} Retrieve API Key APIKeys list GET /v1/orgs/self/users/{user}/apikeys List API Keys APIKeys update POST /v1/orgs/self/users/{user}/apikeys/{name} Update API Key State Aliases create POST /v1/orgs/self/ws/{workspace}/aliases Create Alias Aliases delete DELETE /v1/orgs/self/ws/{workspace}/aliases/{alias} Delete Alias Aliases get GET /v1/orgs/self/ws/{workspace}/aliases/{alias} Retrieve Alias Aliases list GET /v1/orgs/self/aliases List Aliases Aliases update POST /v1/orgs/self/ws/{workspace}/aliases/{alias} Update Alias Aliases workspace_aliases GET /v1/orgs/self/ws/{workspace}/aliases List Aliases in Workspace Collections create_azure_blob_storage_collection POST /v1/orgs/self/ws/{workspace}/collections Create azure blob storage collection Collections create_azure_event_hubs_collection POST /v1/orgs/self/ws/{workspace}/collections Create azure event hubs collection Collections create_dynamodb_collection POST /v1/orgs/self/ws/{workspace}/collections Create dynamodb collection Collections create_gcs_collection POST /v1/orgs/self/ws/{workspace}/collections Create gcs collection Collections create_kafka_collection POST /v1/orgs/self/ws/{workspace}/collections Create kafka collection Collections create_kinesis_collection POST /v1/orgs/self/ws/{workspace}/collections Create kinesis collection Collections create_mongodb_collection POST /v1/orgs/self/ws/{workspace}/collections Create mongodb collection Collections create_s3_collection POST /v1/orgs/self/ws/{workspace}/collections Create s3 collection Collections create_snowflake_collection POST /v1/orgs/self/ws/{workspace}/collections Create snowflake collection Collections delete DELETE /v1/orgs/self/ws/{workspace}/collections/{collection} Delete Collection Collections get GET /v1/orgs/self/ws/{workspace}/collections/{collection} Retrieve Collection Collections get_collection_offsets POST /v1/orgs/self/ws/{workspace}/collections/{collection}/offsets/commit Get Collection Commit Collections list GET /v1/orgs/self/collections List Collections Collections update PUT /v1/orgs/self/ws/{workspace}/collections/{collection} Update Collection Collections workspace_collections GET /v1/orgs/self/ws/{workspace}/collections List Collections in Workspace CustomRoles create POST /v1/orgs/self/roles Create a Role CustomRoles delete DELETE /v1/orgs/self/roles/{roleName} Delete a Role CustomRoles get GET /v1/orgs/self/roles/{roleName} Retrieve role CustomRoles list GET /v1/orgs/self/roles List Roles CustomRoles update POST /v1/orgs/self/roles/{roleName} Update a Role DeploymentSettings get_deployment_settings GET /v1/orgs/self/deploymentsettings Retrieve Deployment Settings DeploymentSettings update_deployment_settings PUT /v1/orgs/self/deploymentsettings Update Deployment Settings Documents add_documents POST /v1/orgs/self/ws/{workspace}/collections/{collection}/docs Add Documents Documents delete_documents DELETE /v1/orgs/self/ws/{workspace}/collections/{collection}/docs Delete Documents Documents patch_documents PATCH /v1/orgs/self/ws/{workspace}/collections/{collection}/docs Patch Documents Integrations create_azure_blob_storage_integration POST /v1/orgs/self/integrations Create azure blob storage integration Integrations create_azure_event_hubs_integration POST /v1/orgs/self/integrations Create azure event hubs integration Integrations create_dynamodb_integration POST /v1/orgs/self/integrations Create dynamodb integration Integrations create_gcs_integration POST /v1/orgs/self/integrations Create gcs integration Integrations create_kafka_integration POST /v1/orgs/self/integrations Create kafka integration Integrations create_kinesis_integration POST /v1/orgs/self/integrations Create kinesis integration Integrations create_mongodb_integration POST /v1/orgs/self/integrations Create mongodb integration Integrations create_s3_integration POST /v1/orgs/self/integrations Create s3 integration Integrations create_snowflake_integration POST /v1/orgs/self/integrations Create snowflake integration Integrations delete DELETE /v1/orgs/self/integrations/{integration} Delete Integration Integrations get GET /v1/orgs/self/integrations/{integration} Retrieve Integration Integrations list GET /v1/orgs/self/integrations List Integrations Integrations update PUT /v1/orgs/self/integrations/{integration} Update Integration Organizations get GET /v1/orgs/self Get Organization Queries cancel_query DELETE /v1/orgs/self/queries/{queryId} Cancel Query Queries get_query GET /v1/orgs/self/queries/{queryId} Retrieve Query Queries get_query_results GET /v1/orgs/self/queries/{queryId}/pages Retrieve Query Results Page Queries list_active_queries GET /v1/orgs/self/queries List Queries Queries query POST /v1/orgs/self/queries Execute SQL Query Queries validate POST /v1/orgs/self/queries/validations Validate Query QueryLambdas create_query_lambda POST /v1/orgs/self/ws/{workspace}/lambdas Create Query Lambda QueryLambdas create_query_lambda_tag POST /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda}/tags Create Query Lambda Tag QueryLambdas delete_query_lambda DELETE /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda} Delete Query Lambda QueryLambdas delete_query_lambda_tag DELETE /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda}/tags/{tag} Delete Query Lambda Tag Version QueryLambdas delete_query_lambda_version DELETE /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda}/version/{version} Delete Query Lambda Version QueryLambdas execute_query_lambda POST /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda}/versions/{version} Execute Query Lambda By Version QueryLambdas execute_query_lambda_by_tag POST /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda}/tags/{tag} Execute Query Lambda By Tag QueryLambdas get_query_lambda_tag_version GET /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda}/tags/{tag} Retrieve Query Lambda Tag QueryLambdas get_query_lambda_version GET /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda}/versions/{version} Retrieve Query Lambda Version QueryLambdas list_all_query_lambdas GET /v1/orgs/self/lambdas List Query Lambdas QueryLambdas list_query_lambda_tags GET /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda}/tags List Query Lambda Tags QueryLambdas list_query_lambda_versions GET /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda}/versions List Query Lambda Versions QueryLambdas list_query_lambdas_in_workspace GET /v1/orgs/self/ws/{workspace}/lambdas List Query Lambdas in Workspace QueryLambdas update_query_lambda POST /v1/orgs/self/ws/{workspace}/lambdas/{queryLambda}/versions Update Query Lambda ScheduledLambdas create POST /v1/orgs/self/ws/{workspace}/scheduled_lambdas Create a Scheduled Lambda mapping ScheduledLambdas delete DELETE /v1/orgs/self/ws/{workspace}/scheduled_lambdas/{scheduledLambdaId} Delete a Scheduled Lambda mapping ScheduledLambdas get GET /v1/orgs/self/ws/{workspace}/scheduled_lambdas/{scheduledLambdaId} Retrieve a Scheduled Lambda mapping ScheduledLambdas list_org_scheduled_lambdas GET /v1/orgs/self/lambdas/scheduled_lambdas List Scheduled Lambdas ScheduledLambdas update POST /v1/orgs/self/ws/{workspace}/scheduled_lambdas/{scheduledLambdaId} Update a Scheduled Lambda mapping SharedLambdas execute_public_query_lambda_with_params POST /v1/public/shared_lambdas/{public_access_id} Execute a Public Query Lambda Sources create_azure_blob_storage_source POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources Create a new azure blob storage source in a collection Sources create_azure_event_hubs_source POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources Create a new azure event hubs source in a collection Sources create_dynamodb_source POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources Create a new dynamodb source in a collection Sources create_gcs_source POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources Create a new gcs source in a collection Sources create_kafka_source POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources Create a new kafka source in a collection Sources create_kinesis_source POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources Create a new kinesis source in a collection Sources create_mongodb_source POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources Create a new mongodb source in a collection Sources create_s3_source POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources Create a new s3 source in a collection Sources create_snowflake_source POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources Create a new snowflake source in a collection Sources delete DELETE /v1/orgs/self/ws/{workspace}/collections/{collection}/sources/{source} Delete Collection source Sources get GET /v1/orgs/self/ws/{workspace}/collections/{collection}/sources/{source} Retrieve source Sources list GET /v1/orgs/self/ws/{workspace}/collections/{collection}/sources List sources in collection Sources resume POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources/{source}/resume Resume source ingest Sources suspend POST /v1/orgs/self/ws/{workspace}/collections/{collection}/sources/{source}/suspend Suspend source ingest Sources update PUT /v1/orgs/self/ws/{workspace}/collections/{collection}/sources/{source} Update a collection source Users create POST /v1/orgs/self/users Create User Users delete DELETE /v1/orgs/self/users/{user} Delete User Users get GET /v1/orgs/self/users/{user} Retrieve User Users get_current_user GET /v1/orgs/self/users/self Retrieve Current User Users list GET /v1/orgs/self/users List Users Users list_unsubscribe_preferences GET /v1/orgs/self/users/self/preferences Retrieve Notification Preferences Users update POST /v1/orgs/self/users/{user} Update User Users update_unsubscribe_preferences POST /v1/orgs/self/users/self/preferences Update Notification Preferences Views create POST /v1/orgs/self/ws/{workspace}/views Create View Views delete DELETE /v1/orgs/self/ws/{workspace}/views/{view} Delete View Views get GET /v1/orgs/self/ws/{workspace}/views/{view} Retrieve View Views list GET /v1/orgs/self/views List Views Views update POST /v1/orgs/self/ws/{workspace}/views/{view} Update View Views workspace_views GET /v1/orgs/self/ws/{workspace}/views List Views in Workspace VirtualInstances create POST /v1/orgs/self/virtualinstances Create Virtual Instance VirtualInstances delete DELETE /v1/orgs/self/virtualinstances/{virtualInstanceId} Delete Virtual Instance VirtualInstances get GET /v1/orgs/self/virtualinstances/{virtualInstanceId} Retrieve Virtual Instance VirtualInstances get_collection_mount GET /v1/orgs/self/virtualinstances/{virtualInstanceId}/mounts/{collectionPath} Get Collection Mount VirtualInstances get_mount_offsets POST /v1/orgs/self/virtualinstances/{virtualInstanceId}/mounts/{collectionPath}/offsets/commit Get Collection Commit VirtualInstances get_virtual_instance_queries GET /v1/orgs/self/virtualinstances/{virtualInstanceId}/queries List Queries VirtualInstances list GET /v1/orgs/self/virtualinstances List Virtual Instances VirtualInstances list_collection_mounts GET /v1/orgs/self/virtualinstances/{virtualInstanceId}/mounts List Collection Mounts VirtualInstances mount_collection POST /v1/orgs/self/virtualinstances/{virtualInstanceId}/mounts Mount Collections VirtualInstances query_virtual_instance POST /v1/orgs/self/virtualinstances/{virtualInstanceId}/queries Execute SQL Query on a specific Virtual Instance VirtualInstances resume_virtual_instance POST /v1/orgs/self/virtualinstances/{virtualInstanceId}/resume Resume Virtual Instance VirtualInstances suspend_virtual_instance POST /v1/orgs/self/virtualinstances/{virtualInstanceId}/suspend Suspend Virtual Instance VirtualInstances unmount_collection DELETE /v1/orgs/self/virtualinstances/{virtualInstanceId}/mounts/{collectionPath} Unmount Collection VirtualInstances update POST /v1/orgs/self/virtualinstances/{virtualInstanceId} Update Virtual Instance Workspaces create POST /v1/orgs/self/ws Create Workspace Workspaces delete DELETE /v1/orgs/self/ws/{workspace} Delete Workspace Workspaces get GET /v1/orgs/self/ws/{workspace} Retrieve Workspace Workspaces list GET /v1/orgs/self/ws List Workspaces
Documentation For Authorization
The RocksetClient object must be instantiated with an apikey. You can create your first apikey in the Rockset console. The provided apikey will be used for all requests that are made using the instance of the client.
Rockset
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4