Skip to main content

Python API Client for CCC

Project description

ccc_client

This package provides a simple, modular SDK for the CCC REST API.

Features

  • Automatically handles authentication and renewal
  • Graceful error management
  • Logically organized modules
  • Easily maintained

Installation

Install using pip:

pip install cccAPI 

Install from source:

git clone https://github.hpe.com/hpe/cccAPI.git
cd cccAPI
pip install -e .

Quick Start

Initialize the Client

  • Install prerequisites: pip install requests jsonschema
  • Simple usage
import json
from cccAPI import cccAPIClient
client = cccAPIClient("https://localhost:8000/cmu/v1", "root", "your-password")

Example Usage

Get Nodes

nodes = client.nodes.show_nodes()
print(json.dumps(nodes, indent=4))

Get specific Node

#Specific node named BartC01n1-091
node = client.nodes.show_node("BartC01n1-091")
print(json.dumps(node, indent=4))

Get specific Node/fields

  • Allowed fields are:
query_params = {"fields": "name,id,uuid,network.name,network.ipAddress,network.macAddress"}
specific_nodes=client.nodes.show_nodes(query_params)
print(json.dumps(specific_nodes, indent=4))

See examples/test.py for other test cases as implemented

API Modules

Module Description User Guide Section
nodes Node Operations
                  - Create/Delete/Update/List Nodes
                  - Add/Remove nodes in image/no-image/network group
                  - Get/Add actions/features of node 
                |   Section 4.5  | 

| image_groups | Image Group Operations | Section 4.3 | | network_groups | Network Group Operations | Section 4.4 | | custom_groups | Custom Group Operations | Section 4.2 | | resource_features | Resource Features | ------------- | | image_capture_deployment | Image Capture Deployment | --------------- | | power_operation | Power operations | | application | application entrypoints, settings | Section 4.1 | | architecture | architecture | -------------- | | management_cards | View network devices, interfaces, routes | ------------- | | tasks | Tasks Operations | Section 4.7 | | conn | Sessions Operations | Section 4.6 |

Building package

Locally

pip install .

or

pip install pip-tools
pip-compile pyproject.toml  #This will produce requirements.txt
pip install -r requirements.txt

or

curl -LsSf https://astral.sh/uv/install.sh | sh.
uv lock 
RUN uv pip install -e . --system

or

pip install build
# Build the package
python -m build
#Creates dist/ with tar.gz and .whl

Publishing

  • Verify ~/.pypirc has PyPi token
pip install setuptools wheel twine
#This will create a dist directory containing the .tar.gz and .whl files for the package
python3 setup.py sdist bdist_wheel
#pip install dist/cccAPI-0.0.1-py3-none-any.whl
pip install twine
twine upload dist/*

License

This project is license under the MIT license.

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

cccapi-0.0.8.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

cccapi-0.0.8-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file cccapi-0.0.8.tar.gz.

File metadata

  • Download URL: cccapi-0.0.8.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for cccapi-0.0.8.tar.gz
Algorithm Hash digest
SHA256 2fea018bc1b288b53fdbf5f0e960a636d911a8cef824aa29f0ceb14f0c45c1f4
MD5 11268d52acc1057f08e757402e76a0b3
BLAKE2b-256 d29b14e02b9c649bcdc84af010d3512a0d17277df2410d4232f95257a495055e

See more details on using hashes here.

File details

Details for the file cccapi-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: cccapi-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for cccapi-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 84097d463995d16d7381780197e2c1fabe5a5717145b04a2f656e13e1c362b10
MD5 5a03d5dabe7893931997a36c4b0798e6
BLAKE2b-256 5e5a785b1b041fef9f4997cc112a17fa75acef250fb07ecf007c5f52f2baa0e6

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