Skip to main content

OpsBeacon python client library to interact with the OpsBeacon API

Project description

OpsBeaconClient Python Library

Overview

OpsBeaconClient is a Python library that provides a simple interface to interact with the OpsBeacon API. This client allows you to manage commands, connections, users, groups, files, and applications within an OpsBeacon workspace.

Installation

pip install opsbeacon

Getting Started

Initialize the Client

To start using the OpsBeaconClient, instantiate the client with your API domain and API token:

from opsbeacon_client import OpsBeaconClient

client = OpsBeaconClient(api_domain="api.yourdomain.com", api_token="your_api_token")

API Methods

Commands

  • Fetch commands: client.commands()

    commands = client.commands()

Connections

  • Fetch connections: client.connections()

    connections = client.connections()

Users

  • Fetch users: client.users()

    users = client.users()

  • Add user: client.add_user(user: Dict[str, Any])

    new_user = {"username": "jdoe", "email": "jdoe@example.com"} success = client.add_user(new_user)

  • Delete user: client.delete_user(user_id: str)

    success = client.delete_user("user_id_123")

Groups

  • Fetch groups: client.groups()

    groups = client.groups()

  • Add group: client.add_group(group: Dict[str, Any])

    new_group = {"name": "admin_group", "permissions": ["read", "write"]} success = client.add_group(new_group)

  • Delete group: client.delete_group(group_name: str)

    success = client.delete_group("admin_group")

File Management

  • Upload file: client.file_upload(file_content: str, file_name: str)

    success = client.file_upload(file_content="data", file_name="data.csv")

  • Download file: client.file_download(file_name: str, destination_path: str)

    success = client.file_download("report.csv", destination_path="/path/to/save")

Command Execution

  • Run command: client.run(command_text: str, connection: str, command: str, args: str)

    response = client.run(command_text="ls -l")

Applications

  • Create or Update an Application: client.create_or_update_app(app_json: Dict[str, Any])

    app_details = {"name": "MyApp", "version": "1.0"} response = client.create_or_update_app(app_details)

Error Handling

The library catches requests.RequestException errors and outputs them to the console. Each method returns False or an empty list if the request fails. Make sure to handle these cases in your implementation.

Example Usage

from opsbeacon_client import OpsBeaconClient

Initialize the client

client = OpsBeaconClient(api_domain="api.yourdomain.com", api_token="your_api_token")

Fetch and print commands

commands = client.commands()
print("Commands:", commands)

Add a new user

new_user = {"username": "jdoe", "email": "jdoe@example.com"}
success = client.add_user(new_user)
if success:
    print("User added successfully.")
else:
    print("Failed to add user.")

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contributing

Feel free to submit issues or pull requests to improve this library.

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

opsbeacon-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opsbeacon-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file opsbeacon-0.1.0.tar.gz.

File metadata

  • Download URL: opsbeacon-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for opsbeacon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 777d5b4728d28224a5c75b5a66b9eab1a714007cefa92ecf023152f0b5413a8e
MD5 7990d26bd9dc36d6eecc761a6262b56a
BLAKE2b-256 29beaabe0e2c19d54f1eca2e1bd5d8d2099d10dedbc9687316920702e3f90360

See more details on using hashes here.

File details

Details for the file opsbeacon-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: opsbeacon-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for opsbeacon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e72ff1d30764d7cf71030c116642f4976193bdc314e6782ed9e7114bd0aa491
MD5 24ab6d7860d96f06b84d053045c7e433
BLAKE2b-256 e77f15319f0657135a87c7df8080244bf81c322d5f38b7d93a0026e726ef2bde

See more details on using hashes here.

Supported by

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