CODE_INFO.md

December 20, 2017 ยท View on GitHub

nis-python-client code guide

main module: nemnis


Requirements:

requests requests-mock


Classes:


class Account

Implements account related methods from API.

Methods:

class BlockChain

Implements block chain related methods from API.

Methods:

class Client

Class that represents main API client.Make calls to NIS via related methods.
For all required information, please follow:

here.
All available methods documentation is also can be found there.

Methods:

  • __init__(self, endpoint='http://127.0.0.1:7890')

    Initialize client.

    • endpoint: address of the NIS.
  • call(self, method, name, params=None, payload=None, **kwargs)

    Make calls to the API via HTTP methods and passed params.
    Methods that uses this method returns response object.

    • method: HTTP method of the request ('GET', 'POST').
    • name: name of the API endpoint method. Appends to base URL.
    • params: GET method params, used when method is GET.
    • payload: POST method data, used when method is POST.
    • kwargs: any additional arguments.
    • return: response object.
  • heartbeat(self)

    Implements heart-beat-request.
    Determines if NIS is up and responsive.
    If there is no response to this request, NIS is either not running or
    is in a state where it can't serve requests.

  • status(self)

    Implements status-request
    Determines the status of NIS.
    If there is no response to this request, NIS is either not running or
    is in a state where it can't serve requests

Properties:

  • account

    Represents account related requests from API.

    • return: Account instance for use with it's methods.
  • blockchain

    Represents block chain related requests from API.

    • return: BlockChain instance for use with it's methods.
  • debug

    Represents requests for additional information from NIS.

    • return: Debug instance for use with its methods.
  • namespace

    Represents namespaces related requests from API.

    • return: Namespace instance for use with its methods.
  • node

    Represents node related requests from API.

    • return: Node instance for use with its methods.
  • transaction

    Represents transaction related requests methods from API.

    • return: Transaction instance for use with its methods.

class Debug

Implements requests for additional information from NIS.

Methods:

  • __init__(self, client)

    Initialize self. See help(type(self)) for accurate signature.

    • client: Client instance
  • connections_incoming(self)

    Gets an audit collection of incoming calls.
    You can monitor the outstanding and recent incoming requests with
    this information.

  • connections_outgoing(self)

    Gets an audit collection of outgoing calls.
    You can monitor the outstanding and recent outgoing requests with
    this information.

  • time_synchronization(self)

    Gets an array of time synchronization results.
    You can monitor the change in network time with this information.

  • timers(self)

    Gets an array of task monitor structures.
    You can monitor the statistics for periodic tasks with
    this information.

class Namespace

Implements namespace related methods from API.

Methods:

  • __init__(self, client)

    Initialize self. See help(type(self)) for accurate signature.

    • client: Client instance
  • mosaic_definition_page(self, namespace, _id=None, pagesize=25)

    Gets the mosaic definitions for a given namespace.

    • namespace: the namespace id.
    • _id: (optional) the topmost mosaic definition database id up to
      which root mosaic definitions are returned.
      The parameter is optional. If not supplied the most recent
      mosaic definitiona are returned.
    • pagesize: the number of mosaic definition objects to be returned
      for each request. The parameter is optional. The default value
      is 25, the minimum value is 5 and hte maximum value is 100.
  • namespace(self, namespace)

    Gets the namespace with given id.

    • namespace: the namespace id.
  • root_page(self, _id=None, page_size=25)

    Gets the root namespaces.

    • _id: (optional) the topmost namespace database id up to which
      root namespaces are returned
    • page_size: _(optional )_the number of namespace objects to be
      returned for each request. The parameter is optional.
      The default value is 25, the minimum value is 5 and hte maximum
      value is 100.

class Node

Implements node related methods from API.

Methods:

  • __init__(self, client)

    Initialize self. See help(type(self)) for accurate signature.

    • client: Client instance
  • boot(self, boot_node_request)

    Boots the local node and thus assign an account (the identity) to
    the local node.
    In case the node has already been booted, NIS will return a
    JSON error object.

  • experiences(self)

    Gets an array of node experiences from another node.
    In case the node has not been booted yet, NIS will return a
    JSON error object.

  • extended_info(self)

    Gets extended information about a node.
    In case the node has not been booted yet, NIS will return a
    JSON error object.

  • info(self)

    Gets basic information about a node.
    In case the node has not been booted yet, NIS will return a
    JSON error.

  • max_chain_height(self)

    Requests the chain height from every node in the active node list
    and returns the maximum height seen.
    In case the node has not been booted yet, NIS will return a JSON
    error object.

  • peer_list_active(self)

    Gets an array of active nodes in the neighborhood that are selected for
    broadcasts.
    In case the node has not been booted yet, NIS will return a
    JSON error object.

  • peer_list_all(self)

    Gets an array of all known nodes in the neighborhood.
    In case the node has not been booted yet, NIS will return a
    JSON error object.

  • peer_list_reachable(self)

    Gets an array of all nodes with status 'active' in the neighborhood.
    In case the node has not been booted yet, NIS will return a
    JSON error object.

class Transaction

_Implements transaction related methods from API. _ According to documentation, should be used with care!

Methods:

  • __init__(self, client)

    Initialize self. See help(type(self)) for accurate signature.

    • client: Client instance
  • announce(self, request_announce)

    Creates and broadcasts a transaction. The private key is not involved.

  • prepare_announce(self, request_announce)

    Creates and broadcasts a transaction. Since this request involves the private key of an account, it should only be sent to a local NIS. There are various errors that can occur due to failure of transaction validation.