IoticAgent.IOT.ResourceMeta module

Base class for Helper objects for getting and setting metadata programmatically

class IoticAgent.IOT.ResourceMeta.ResourceMeta(parent, rdf, default_lang, fmt='n3')

Bases: object

Base class for metadata helpers. Inherited by:

Do not instantiate directly

delete_description(lang=None)

Deletes all the label metadata properties on your Thing/Point for this language

Raises:ValueError – Contains an error message if the parameters fail validation
Parameters:lang (string, optional) – The two-character ISO 639-1 language code to identify your label. None means use the default language for your agent. See IoticAgent.IOT.Config module
delete_label(lang=None)

Deletes all the label metadata properties on your Thing/Point for this language

Raises:ValueError – Contains an error message if the parameters fail validation
Parameters:lang (string, optional) – The two-character ISO 639-1 language code to identify your label. None means use the default language for your agent. See IoticAgent.IOT.Config module
get_descriptions()

Gets all the description metadata properties on your Thing/Point. Only one description is allowed per language, so you’ll get a list of descriptions in the N3 syntax, e.g. [“fish tank”@en, “aquarium”@fr]

Returns:List of descriptions in N3 format or empty list if none.
get_descriptions_rdf()

Gets all the description metadata properties on your Thing/Point. Only one description is allowed per language, so you’ll get a list of descriptions as rdflib.term.Literals

Returns:List of descriptions as rdflib.term.Literals or empty list if none.
get_labels()

Gets all the label metadata properties on your Thing/Point. Only one label is allowed per language, so you’ll get a list of labels in the N3 syntax, e.g. [“fish”@en, “poisson”@fr]

Returns:List of labels in N3 format
get_labels_rdf()

Gets all the label metadata properties on your Thing/Point. Only one label is allowed per language, so you’ll get a list of labels as rdflib.term.Literal objects

Returns:List of labels as rdflib.term.Literals
set()

Pushes the RDF metadata description back to the infrastructure. This will be searchable if you have called IoticAgent.IOT.Thing module Thing.set_public at any time.

Example 1 - Recommended

Use of python with syntax and XXXXmeta class.

# using with calls set() for you so you don't forget
with thing_solar_panels.get_meta() as meta_thing_solar_panels:
    meta_thing_solar_panels.set_label("Mark's Solar Panels")
    meta_thing_solar_panels.set_description("Solar Array 3.3kW")
    meta_thing_solar_panels.set_location(52.1965071,0.6067687)

Example 2

Explicit use of set

meta_thing_solar_panels = thing_solar_panels.get_meta()

meta_thing_solar_panels.set_label("Mark's Solar Panels")
meta_thing_solar_panels.set_description("Solar Array 3.3kW")
meta_thing_solar_panels.set_location(52.1965071,0.6067687)

meta_thing_solar_panels.set()
Raises:
  • IOTException – Infrastructure problem detected
  • LinkException – Communications problem between you and the infrastructure
  • rdflib.plugins.parsers.notation3.`BadSyntax` – if the RDF is badly formed n3
  • xml.sax._exceptions.`SAXParseException` – if the RDF is badly formed xml
set_description(description, lang=None)

Sets the description metadata property on your Thing/Point. Only one description is allowed per language, so any other descriptions in this language are removed before adding this one

Raises:

ValueError – Contains an error message if the parameters fail validation

Parameters:
  • description (string) – the new text of the description
  • lang (string, optional) – The two-character ISO 639-1 language code to identify your label. None means use the default language for your agent. See IoticAgent.IOT.Config module
set_label(label, lang=None)

Sets the label metadata property on your Thing/Point. Only one label is allowed per language, so any other labels in this language are removed before adding this one

Raises:

ValueError – Contains an error message if the parameters fail validation

Parameters:
  • label (string) – the new text of the label
  • lang (string, optional) – The two-character ISO 639-1 language code to use for your label. None means use the default language for your agent. See IoticAgent.IOT.Config module.
update()

Gets the latest version of your metadata from the infrastructure and updates your local copy

Returns:True if successful, False otherwise

OR

Raises:
  • IOTException – Infrastructure problem detected
  • LinkException – Communications problem between you and the infrastructure