Code Monkey home page Code Monkey logo

ah-acl-py's Introduction

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))

ah-acl-py's People

Contributors

jara001 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.