Skip to main content

A simple python client for interacting with the OSDU API.

Project description

osdupy

A simple python client for the OSDU data platform.

Currently supported methods

  • search
    • query
    • query_with_paging
  • storage
    • query_all_kinds
    • get_record
    • store_records
    • delete_record
  • delivery
    • get_signed_urls

Installation

pip install osdupy

Usage

Initialize the client

If your environment variables (below) have been set, then client.get_client() can be called with no args. Environment variables: OSDU_API_URL, OSDU_CLIENT_ID, OSDU_USER, OSDU_PASSWORD

from osdu.client import AwsOsduClient

data_partition = 'opendes'

osdu = AwsOsduClient(data_partition)

If you have not set the above environment variales, then you will need to pass any undefined as args when instantiating the client.

from getpass import getpass()
from osdu.client import AwsOsduClient

api_url = 'https://your_api_url'
client_id = 'YOURCLIENTID'
user = 'username@testing.com'
password = getpass()
data_partition = 'yourpartition'

osdu = AwsOsduClient(data_partition, api_url, client_id, user, password)

Use the client

# Search for records by query.
query = {
    "kind": f"opendes:osdu:*:*"
}
result = osdu.search.query(query)
# { results: [ {...}, .... ], totalCount: ##### }


# Get a record.
record_id = 'opendes:doc:123456789'
result = osdu.storage.get_record(record_id)
# { 'id': 'opendes:doc:123456789', 'kind': ..., 'data': {...}, 'acl': {...}, .... }

See tests for more copmrehensive usage examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osdupy-0.0.3.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

osdupy-0.0.3-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page