Skip to content

opalsecurity/opal-python

Repository files navigation

opal-security

The Opal API is a RESTful API that allows you to interact with the Opal Security platform programmatically.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 1.0
  • Releases
  • Generator version: 7.10.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

For more information, please visit https://www.opal.dev/

Requirements.

Python 3.8+

Installation & Usage

pip install

We recommend installing from PyPI using pip:

pip install opal-security

You can also install via git:

pip install git+https://github.com/opalsecurity/opal-python.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/opalsecurity/opal-python.git)

Then import the package:

import opal_security as opal

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import opal_security as opal

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

from opal_security.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.opal.dev/v1
# See configuration.py for a list of all supported configuration parameters.
import opal_security as opal

configuration = opal.Configuration(
    host = "https://api.opal.dev/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 = opal.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)


# Enter a context with an instance of the API client
with opal.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = opal.AppsApi(api_client)
    app_id = '32acc112-21ff-4669-91c2-21e27683eaa1' # str | The ID of the app.

    try:
        api_response = api_instance.get_app(app_id)
        print("The response of AppsApi->get_app:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling AppsApi->get_app: %s\n" % e)

Example with Events API:

import time
import opal_security as opal
from pprint import pprint
# Defining the host is optional and defaults to https://api.opal.dev/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = opal.Configuration(
    host = "https://api.opal.dev/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 = opal.Configuration(
    access_token = 'YOUR_BEARER_TOKEN'
)


# Enter a context with an instance of the API client
with opal.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = opal.EventsApi(api_client)
    start_date_filter = "2021/11/01" # str | A start date filter for the events. (optional)
    end_date_filter = "2021-11-12" # str | An end date filter for the events. (optional)
    actor_filter = "29827fb8-f2dd-4e80-9576-28e31e9934ac" # str | An actor filter for the events. Supply the ID of the actor. (optional)
    object_filter = "29827fb8-f2dd-4e80-9576-28e31e9934ac" # str | An object filter for the events. Supply the ID of the object. (optional)
    event_type_filter = "29827fb8-f2dd-4e80-9576-28e31e9934ac" # str | An event type filter for the events. (optional)
    cursor = "cD0yMDIxLTAxLTA2KzAzJTNBMjQlM0E1My40MzQzMjYlMkIwMCUzQTAw" # str | The pagination cursor value. (optional)
    page_size = 200 # int | Number of results to return per page. Default is 200. (optional)

    try:
        api_response = api_instance.events(start_date_filter=start_date_filter, end_date_filter=end_date_filter, actor_filter=actor_filter, object_filter=object_filter, event_type_filter=event_type_filter, cursor=cursor, page_size=page_size)
        pprint(api_response.dict())
    except opal.ApiException as e:
        print("Exception when calling EventsApi->events: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.opal.dev/v1

Class Method HTTP request Description
AppsApi get_app GET /apps/{app_id}
AppsApi get_apps GET /apps
AppsApi get_sync_errors GET /sync_errors
ConfigurationTemplatesApi create_configuration_template POST /configuration-templates
ConfigurationTemplatesApi delete_configuration_template DELETE /configuration-templates/{configuration_template_id}
ConfigurationTemplatesApi get_configuration_templates GET /configuration-templates
ConfigurationTemplatesApi update_configuration_template PUT /configuration-templates
EventsApi events GET /events
GroupBindingsApi create_group_binding POST /group-bindings
GroupBindingsApi delete_group_binding DELETE /group-bindings/{group_binding_id}
GroupBindingsApi get_group_binding GET /group-bindings/{group_binding_id}
GroupBindingsApi get_group_bindings GET /group-bindings
GroupBindingsApi update_group_bindings PUT /group-bindings
GroupsApi add_group_resource POST /groups/{group_id}/resources/{resource_id}
GroupsApi add_group_user POST /groups/{group_id}/users/{user_id}
GroupsApi create_group POST /groups
GroupsApi delete_group DELETE /groups/{group_id}
GroupsApi delete_group_user DELETE /groups/{group_id}/users/{user_id}
GroupsApi get_group GET /groups/{group_id}
GroupsApi get_group_message_channels GET /groups/{group_id}/message-channels
GroupsApi get_group_on_call_schedules GET /groups/{group_id}/on-call-schedules
GroupsApi get_group_resources GET /groups/{group_id}/resources
GroupsApi get_group_reviewer_stages GET /groups/{group_id}/reviewer-stages
GroupsApi get_group_reviewers GET /groups/{group_id}/reviewers
GroupsApi get_group_tags GET /groups/{group_id}/tags
GroupsApi get_group_users GET /groups/{group_id}/users
GroupsApi get_group_visibility GET /groups/{group_id}/visibility
GroupsApi get_groups GET /groups
GroupsApi set_group_message_channels PUT /groups/{group_id}/message-channels
GroupsApi set_group_on_call_schedules PUT /groups/{group_id}/on-call-schedules
GroupsApi set_group_resources PUT /groups/{group_id}/resources
GroupsApi set_group_reviewer_stages PUT /groups/{group_id}/reviewer-stages
GroupsApi set_group_reviewers PUT /groups/{group_id}/reviewers
GroupsApi set_group_visibility PUT /groups/{group_id}/visibility
GroupsApi update_groups PUT /groups
IdpGroupMappingsApi delete_idp_group_mappings DELETE /idp-group-mappings/{app_resource_id}/{group_id}/
IdpGroupMappingsApi get_idp_group_mappings GET /idp-group-mappings/{app_resource_id}
IdpGroupMappingsApi update_idp_group_mappings PUT /idp-group-mappings/{app_resource_id}
MessageChannelsApi create_message_channel POST /message-channels
MessageChannelsApi get_message_channel GET /message-channels/{message_channel_id}
MessageChannelsApi get_message_channels GET /message-channels
NonHumanIdentitiesApi get_nhis GET /non-human-identities
OnCallSchedulesApi create_on_call_schedule POST /on-call-schedules
OnCallSchedulesApi get_on_call_schedule GET /on-call-schedules/{on_call_schedule_id}
OnCallSchedulesApi get_on_call_schedules GET /on-call-schedules
OwnersApi create_owner POST /owners
OwnersApi delete_owner DELETE /owners/{owner_id}
OwnersApi get_owner GET /owners/{owner_id}
OwnersApi get_owner_from_name GET /owners/name/{owner_name}
OwnersApi get_owner_users GET /owners/{owner_id}/users
OwnersApi get_owners GET /owners
OwnersApi set_owner_users PUT /owners/{owner_id}/users
OwnersApi update_owners PUT /owners
RequestsApi create_request POST /requests
RequestsApi get_requests GET /requests
ResourcesApi add_resource_nhi POST /resources/{resource_id}/non-human-identities/{non_human_identity_id}
ResourcesApi add_resource_user POST /resources/{resource_id}/users/{user_id}
ResourcesApi create_resource POST /resources
ResourcesApi delete_resource DELETE /resources/{resource_id}
ResourcesApi delete_resource_nhi DELETE /resources/{resource_id}/non-human-identities/{non_human_identity_id}
ResourcesApi delete_resource_user DELETE /resources/{resource_id}/users/{user_id}
ResourcesApi get_resource GET /resources/{resource_id}
ResourcesApi get_resource_message_channels GET /resources/{resource_id}/message-channels
ResourcesApi get_resource_nhis GET /resources/{resource_id}/non-human-identities
ResourcesApi get_resource_reviewer_stages GET /resources/{resource_id}/reviewer-stages
ResourcesApi get_resource_reviewers GET /resources/{resource_id}/reviewers
ResourcesApi get_resource_tags GET /resources/{resource_id}/tags
ResourcesApi get_resource_users GET /resources/{resource_id}/users
ResourcesApi get_resource_visibility GET /resources/{resource_id}/visibility
ResourcesApi get_resources GET /resources
ResourcesApi resource_user_access_status_retrieve GET /resource-user-access-status/{resource_id}/{user_id}
ResourcesApi set_resource_message_channels PUT /resources/{resource_id}/message-channels
ResourcesApi set_resource_reviewer_stages PUT /resources/{resource_id}/reviewer-stages
ResourcesApi set_resource_reviewers PUT /resources/{resource_id}/reviewers
ResourcesApi set_resource_visibility PUT /resources/{resource_id}/visibility
ResourcesApi update_resources PUT /resources
SessionsApi sessions GET /sessions
TagsApi add_group_tag POST /tags/{tag_id}/groups/{group_id}
TagsApi add_resource_tag POST /tags/{tag_id}/resources/{resource_id}
TagsApi add_user_tag POST /tags/{tag_id}/users/{user_id}
TagsApi create_tag POST /tag
TagsApi delete_tag_by_id DELETE /tag/{tag_id}
TagsApi get_tag GET /tag
TagsApi get_tag_by_id GET /tag/{tag_id}
TagsApi get_tags GET /tags
TagsApi remove_group_tag DELETE /tags/{tag_id}/groups/{group_id}
TagsApi remove_resource_tag DELETE /tags/{tag_id}/resources/{resource_id}
TagsApi remove_user_tag DELETE /tags/{tag_id}/users/{user_id}
UarsApi create_uar POST /uar
UarsApi get_uar GET /uar/{uar_id}
UarsApi get_uars GET /uars
UsersApi get_user_tags GET /users/{user_id}/tags
UsersApi get_users GET /users
UsersApi user GET /user

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

BearerAuth

  • Type: Bearer authentication

Author

[email protected]