client Package — Personis 12.9 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Personis 12.9 documentation »
- personis Package »

# client Package

## `client` Package

class `personis.client.` `Access`(model='-', connection=None, uri=None, credentials=None, http=None, loglevel=20, test=True)

  Bases: `object`

  Client version of access for client/server system

  Parameters: | model – (string) - model name. If none, then default user model. (‘-‘ maps to the model of the authenticated user) connection – (Connection) - Connection to use connecting to server. If none, you need to provide a URI or credentials uri – (string) - URI of personis server. Need either this or credentials, or a connection. credentials – (Credentials) - Credentials for a connection (if no connection or URI provided.) http – (httplib2.Http) - Http connection to use. loglevel – (int) - Configure logging. test – (boolean) - default to true. If false, the test connection to the server is not done, for speed if connections are established repeatedly.

  `ask`(context=[], view=None, resolver=None, showcontexts=None)

    Ask personis for some information

    Parameters: | context – (list) - The path of context identifiers view – (list or string) - either: - an identifier of a view in the context specified - a list of component identifiers or full path lists - None indicating that the values of all components in the context be returned resolver – (string) - specifies a resolver, default is the builtin resolver
    Returns: | a list of matched components

  `delcomponent`(context=[], componentid=None)

    Delete an existing component in a given context

    Parameters: | context – a list giving the path to the required context componentid – the id for a component
    Returns: | None on success or a string error message on error
    Raise : |

  `delcontext`(context=[])

    Delete an existing context

    Parameters: | context – a list giving the path to the required context
    Returns: | None on success or a string error message on error
    Raise : |

  `delete_sub`(context=[], componentid=None, subname=None)

    Parameters: | context – is a list giving the path of context identifiers componentid – designates the component subscribed to subname – is the subscription name
    Returns: | None on success or a string error message on error

  `deleteapp`(app=None)

    deletes an app

    Returns: | None on success or a string error message on error

  `delview`(context=[], viewid=None)

    Delete an existing view in a given context

    Parameters: | context – a list giving the path to the required context viewid – the id for the view
    Returns: | None on success or a string error message on error

  `export_model`(context=[], resolver=None)

    - - Parameters: | context – is the context to export resolver – is a string containing the name of a resolver or resolver is a dictionary containing information about resolver(s) to be used and arguments:
            the "resolver" key gives the name of a resolver to use, if not present the default resolver is used
            the "evidence_filter" key specifies an evidence filter
            eg 'evidence_filter' =  "all" returns all evidence,
                                    "last10" returns last 10 evidence items,
                                    "last1" returns most recent evidence item,
                                    None returns no evidence
    Returns: | A json model dump or a string error message on error

  `getcontext`(context=[], getsize=False)

    Get context information

    Parameters: | context – a list giving the path to the required context getsize – True if the size in bytes of the context subtree is required
    Returns: | A context, or a string error message on error

  `getpermission`(context=None, componentid=None, app=None)

    gets permissions for a context (if componentid is None) or a component

    Returns: | a tuple (ask,tell) on success or a string error message on error

  `getresolvers`()

    Return a list of the available resolver names

  `import_model`(context=[], partial_model=None)

    Parameters: | context – is the context to import into partial_modeL – is a json encoded string containing the partial model
    Returns: | None on success or a string error message on error

  `list_subs`(context=[], componentid=None)

    Parameters: | context – is a list giving the path of context identifiers componentid – designates the component with subscriptions attached
    Returns: | A list of subscriptions or a string error message on error

  `listapps`()

    returns array of registered app names

    Returns: | A list of apps or a string error message on error

  `mkcomponent`(context=[], componentobj=None)

    Make a new component in a given context

    Parameters: | context – a list giving the path to the required context componentobj – a Component object
    Returns: | None on success or a string error message on error
    Raise : |

  `mkcontext`(context=[], contextobj=None)

    Make a new context in a given context

    Parameters: | context – a list giving the path to the required context contextobj – a Context object
    Returns: | None on success or a string error message on error

  `mkview`(context=[], viewobj=None)

    Make a new view in a given context

    Parameters: | context – a list giving the path to the required context viewobj – a View object
    Returns: | None on success or a string error message on error

  `registerapp`(app=None, desc='', password=None, realm='password')

    registers a password for an app

    Parameters: | app – name is a string (needs checking TODO) desc – (str) description of app password – app passwords are stored at the top level .model db
    Returns: | None on success or a string error message on error

  `set_goals`(context=[], componentid=None, goals=None)

    Parameters: | context – is a list giving the path of context identifiers componentid – designates the component with subscriptions attached goals – is a list of paths to components that are: - goals for this componentid if it is not of type goal - components that contribute to this componentid if it is of type goal
    Returns: | None on success or a string error message on error

  `setpermission`(context=None, componentid=None, app=None, permissions={})

    sets ask/tell permission for a context (if componentid is None) or a component

    Returns: | None on success or a string error message on error

  `setresolver`(context, componentid, resolver)

    set the resolver for a given component in a given context

    Parameters: | context – a list giving the path to the required context componentid – the id for a given component resolver – the id of the resolver
    Returns: | None on success or a string error message on error
    Raise : |

  `subscribe`(context=[], view=None, subscription=None)

    Parameters: | context – is a list giving the path of context identifiers view – is either: an identifier of a view in the context specified a list of component identifiers or full path lists None indicating that the values of all components in the context be returned subscription is a Subscription object
    Returns: | None on success or a string error message on error

  `tell`(context=[], componentid=None, evidence=None)

    Tell the model something.

    Parameters: | context – a list giving the path to the required context componentid – identifier of the component evidence – evidence object to add to the component
    Returns: | None on success or a string error message on error
    Raise : |

class `personis.client.` `Component`(**kargs)

  component object

  Parameters: | Identifier – (string) - The identifier of the component - unique in the context. Description – (string) - Readable description creation_time – (string) - time of creation of the component. component_type – (list) - [“attribute”, “activity”, “knowledge”, “belief”, “preference”, “goal”] value_type – (list) - [“string”, “number”,”boolean”, “enum”, “JSON”] value_list – (list) - a list of strings that are the possible values for type “enum”. value – (string) - the resolved value. resolver – (string) - default resolver for this component. goals – (list) - list of component paths eg [ [‘Personal’, ‘Health’, ‘weight’], ...] evidencelist – (list) - list of evidence objects.

class `personis.client.` `Connection`(uri=None, credentials=None, http=None)

  Bases: `object`

  Connection object

  Contains the state of your connection to personis.

  Parameters: | uri – The uri of a personis server. credentials – (`httplib2.Credentials`) Credentails for connecting to the server. http – (`httplib2.Http`) An http connection to use.

  Note

  Http can be used if you need to configure proxies etc. The class needs either uri or credentials to work.

  `get_http`()

    Get the http connection given in the construction, or in set_http

    Returns: | `httplib2.Http`

  `set_http`(http)

    Set the http connection to use

    Parameters: | http (`httplib2.Http`) – The http connection to use

  `valid`()

    Is this valid?

    Returns: | boolean – is valid.

class `personis.client.` `Context`(**kargs)

  context object

  Parameters: | Identifier – The identifier of the component - unique in the context. Description – Readable description resolver – default resolver for components in this context

class `personis.client.` `Evidence`(**kargs)

  evidence object

  Parameters: | evidence_type – (`EvidenceTypes`) - The type of the evidencelist source – (str) A string indicating the source of the evidence value – (object) - Any python object comment – (str) - string with extra information about the evidence flags – (list) - a list of strings eg “goal” time – (integer) - notional creation time optionally given by user creation_time – (integer) - actual time evidence item was created useby – (integer) - timestamp evidence expires (if required)

  `EvidenceTypes` = ['explicit', 'implicit', 'exmachina', 'inferred', 'stereotype']

    Evidence can be:

    - explicit: given by the user (given)
    - implicit: observed by the machine (observation)
    - exmachina: told (to the user) by the machine (told)
    - inferred: evidence generated by inference (external or internal)
    - stereotype: evidence added by a stereotype

class `personis.client.` `View`(**kargs)

  view object

  Parameters: | Identifier (str) – The identifier of the component - unique in the context. Description (str) – Readable description component_list (list) – List of components in the view
  Returns: |

## `util` Module

`personis.client.util.` `LoginFromClientSecrets`(filename='client_secrets.json', credentials='credentials.dat', http=None)

  Parameters: | filename – credentials – http –
  Returns: |

`personis.client.util.` `MkModel`(model=None, modelserver=None, user=None, password=None, description=None, debug=0)

  Parameters: | model – modelserver – user – password – description – debug –
  Raise : |

`personis.client.util.` `PrintComplist`(reslist, printev=None, count=1)

  Parameters: | reslist – printev – count –

`personis.client.util.` `do_call`(fun, args, connection)

  Parameters: | fun – args – connection –
  Returns: |
  Raise : |

`personis.client.util.` `getOauthCredentialsFromClientSecrets`(credentials='credentials.dat', filename='client_secrets.json', http=None)

  Parameters: | credentials – filename – http –
  Returns: |

`personis.client.util.` `showobj`(obj, indent)

  Parameters: | obj – indent –

### Navigation

- index
- modules |
- next |
- previous |
- Personis 12.9 documentation »
- personis Package »