Skip to content

Very lightweight version of Arrowhead Client Library for Python.

License

Notifications You must be signed in to change notification settings

CTU-IIG/ah-acl-py

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arrowhead Client Library for Python

Very lightweight version for quick projects.

Based on ah-echo-py.

Requirements

  • Python 3
  • requests_pkcs12

Getting started

Download the package and install it using:

python3 -m pip install aclpy-*.whl

Or if you have wagon you can install it along with the dependencies using:

wagon install aclpy-*.wgn

Implemented features

  • ArrowheadConnector + ArrowheadClient
    • Features
      • Register a service
      • Unregister a service
      • Register a system
      • Orchestrate
    • Methods
      • PKCS#12
  • ArrowheadInterface
    • Check validity of interface
    • Created at
    • Updated at
    • Id
  • ArrowheadServer
    • Set IP address
    • Core Systems features
      • Change port
      • Change endpoint
      • Set URL
    • Core Systems
      • Orchestrator
      • ServiceRegistry
      • Authorization
  • ArrowheadService
    • Name
    • Version
    • Interface
    • Security
    • URI
    • End of Validity
    • Metadata
    • Created at
    • Updated at
    • Id
  • ArrowheadSystem
    • Name
    • Address
    • Port
    • AuthenticationInfo
      • Public key
      • Token
    • Created at
    • Updated at
    • Id
    • Interfaces

Usage

ArrowheadServer

from aclpy.server import ArrowheadServer

server = ArrowheadServer()

ArrowheadService

from aclpy.service import ArrowheadService

service = ArrowheadService(
    name = "NAME_OF_THE_SERVICE",
)

ArrowheadInterface

from aclpy.interface import ArrowheadInterface

interface = ArrowheadInterface(
    name = "NAME_OF_THE_INTERFACE",
)

ArrowheadClient

PKCS#12 version

from aclpy.client.client_pkcs12 import ArrowheadClient

client = ArrowheadClient(
    name = "NAME_OF_THE_CLIENT",
    address = "IP_ADDRESS_OF_THE_CLIENT",
    port = PORT_OF_THE_CLIENT,
    # Public key; choose one:
    # pubfile = "PATH_TO_THE_PUB_FILE",     # Method a)
    # pubkey = "....................",      # Method b)
    # Or skip both to obtain it from p12    # Method c)
    p12file = "PATH_TO_THE_P12_FILE",
    p12pass = "PASSWORD_TO_P12_FILE",
    cafile = "PATH_TO_THE_CA_FILE",
    server = server,
)

# Add an interface
client.interfaces.append(interface)

# Register a service
success = client.register_service(service)

# Unregister a service
success = client.unregister_service(service)

# Register the system
success = client.register_system()

# Run the orchestration for service
success, providers = client.orchestrate(service)

Example

# Server configuration
from aclpy.server import ArrowheadServer

# Client / system configuration
from aclpy.client.client_pkcs12 import ArrowheadClient

# Interface configuration
from aclpy.interface import ArrowheadInterface

# Service configuration
from aclpy.service import ArrowheadService


# Define the components
server = ArrowheadServer(
    #address = "127.0.0.1",     # Localhost is default
)

interface = ArrowheadInterface(
    name = "HTTP-INSECURE-JSON",
)

client = ArrowheadClient(
    name = "echoclient",
    address = "127.0.0.1",
    port = 0,                   # As we are only listening
    pubfile = "echoclient.pub", # Path to the public key
    p12file = "echoclient.p12", # Path to the private key
    p12pass = "1111111",        # Password
    cafile = "sysop.ca",        # Path to .ca file
    server = server,
    interfaces = [interface],
)

service = ArrowheadService(
    name = "echo",
)


# Look for the echo server
success, providers = client.orchestrate(service)

print ("Orchestration was %s." % ("SUCCESSFUL" if success else "NOT SUCCESSFUL"))
print ("Found %d providers." % len(providers))

if len(providers) > 0:
    for _i, provider in enumerate(providers):
        print ("%d: %s:%d" % (_i, provider.address, provider.port))

About

Very lightweight version of Arrowhead Client Library for Python.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 94.1%
  • Makefile 3.9%
  • Shell 2.0%