Skip to content

giros-dit/python-ngsi-ld-client

 
 

Repository files navigation

python-ngsi-ld-client

Python client for ETSI GS CIM 009 V1.6.1 cross-cutting Context Information Management (CIM); NGSI-LD API. The OpenAPI specification for the NGSI-LD API is available here.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 1.6.1
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

For more information, please visit https://www.etsi.org/committee/cim

The OpenAPI for NGSI-LD API V1.6.1 from which the Python-based client was generated is available here.

To generate the code derived from the particular schemas defined within the OpenAPI, the OpenAPI Generator Docker image option has been used with the following command executed from the current folder:

$ docker run --rm -v ${PWD}:/python-ngsi-ld-client openapitools/openapi-generator-cli generate -i /python-ngsi-ld-client/schemas/ngsi-ld-api.yaml -g python --package-name ngsi_ld_client -o /python-ngsi-ld-client --additional-properties disallowAdditionalPropertiesIfNotPresent=false --skip-validate-spec

Requirements.

Python 3.7+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import ngsi_ld_client

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import ngsi_ld_client

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import ngsi_ld_client
from ngsi_ld_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://localhost:443/ngsi-ld/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = ngsi_ld_client.Configuration(
    host = "https://localhost:443/ngsi-ld/v1"
)



# Enter a context with an instance of the API client
with ngsi_ld_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = ngsi_ld_client.ContextInformationConsumptionApi(api_client)
    count = True # bool | 6.3.13 Counting number of results. If true, then a special HTTP header (NGSILD-Results-Count) is set in the response. Regardless of how many entities are actually returned (maybe due to the \"limit\" URI parameter), the total number of matching results (e.g. number of Entities) is returned.  (optional)
    limit = 56 # int | 6.3.10 Pagination behaviour. It defines the limit to the number of NGSI-LD Elements that shall be retrieved at a maximum as mandated by clause 5.5.9. The value 0 is only allowed in combination with the count URI parameter.  (optional)
    local = True # bool | 6.3.18 Limiting Distributed Operations. If local=true then no Context Source Registrations shall be considered as matching to avoid cascading distributed operations (see clause 4.3.6.4).  (optional)
    options = [ngsi_ld_client.OptionsRepresentation()] # List[OptionsRepresentation] |  (optional)
    link = 'link_example' # str | 6.3.5 JSON-LD @context resolution  In summary, from a developer's perspective, for POST, PATCH and PUT operations, if MIME type is \"application/ld+json\", then the associated @context shall be provided only as part of the request payload body. Likewise, if MIME type is \"application/json\", then the associated @context shall be provided only by using the JSON-LD Link header. No mixes are allowed, i.e. mixing options shall result in HTTP response errors. Implementations should provide descriptive error messages when these situations arise.  In contrast, GET and DELETE operations always take their input @context from the JSON-LD Link Header.  (optional)
    ngsild_tenant = 'ngsild_tenant_example' # str | 6.3.14 Tenant specification. The tenant to which the NGSI-LD HTTP operation is targeted.  (optional)
    query = ngsi_ld_client.Query() # Query | Payload body in the request contains a JSON-LD object which represents the query to be performed. (optional)

    try:
        # Query entities based on POST 
        api_response = api_instance.query_batch(count=count, limit=limit, local=local, options=options, link=link, ngsild_tenant=ngsild_tenant, query=query)
        print("The response of ContextInformationConsumptionApi->query_batch:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling ContextInformationConsumptionApi->query_batch: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://localhost:443/ngsi-ld/v1

Class Method HTTP request Description
ContextInformationConsumptionApi query_batch POST /entityOperations/query Query entities based on POST
ContextInformationConsumptionApi query_entity GET /entities Query entities
ContextInformationConsumptionApi retrieve_attr_type_info GET /attributes/{attrId} Details about available attribute
ContextInformationConsumptionApi retrieve_attr_types GET /attributes Available attributes
ContextInformationConsumptionApi retrieve_entity GET /entities/{entityId} Entity retrieval by id
ContextInformationConsumptionApi retrieve_entity_type_info GET /types/{type} Details about available entity type
ContextInformationConsumptionApi retrieve_entity_types GET /types Retrieve available entity types
ContextInformationProvisionApi append_attrs POST /entities/{entityId}/attrs Append Attributes to Entity
ContextInformationProvisionApi create_batch POST /entityOperations/create Batch Entity Creation
ContextInformationProvisionApi create_entity POST /entities Entity creation
ContextInformationProvisionApi delete_attrs DELETE /entities/{entityId}/attrs/{attrId} Attribute delete
ContextInformationProvisionApi delete_batch POST /entityOperations/delete Batch Entity Delete
ContextInformationProvisionApi delete_entity DELETE /entities/{entityId} Entity deletion by id
ContextInformationProvisionApi merge_batch POST /entityOperations/merge Batch Entity Merge
ContextInformationProvisionApi merge_entity PATCH /entities/{entityId} Entity merge by id
ContextInformationProvisionApi replace_attrs PUT /entities/{entityId}/attrs/{attrId} Attribute replace
ContextInformationProvisionApi replace_entity PUT /entities/{entityId} Entity replacement by id
ContextInformationProvisionApi update_attrs PATCH /entities/{entityId}/attrs/{attrId} Partial Attribute Update
ContextInformationProvisionApi update_batch POST /entityOperations/update Batch Entity Update
ContextInformationProvisionApi update_entity PATCH /entities/{entityId}/attrs Update Attributes of an Entity
ContextInformationProvisionApi upsert_batch POST /entityOperations/upsert Batch Entity Creation or Update (Upsert)
ContextInformationSubscriptionApi create_subscription POST /subscriptions Create Subscription
ContextInformationSubscriptionApi delete_subscription DELETE /subscriptions/{subscriptionId} Subscription deletion by id
ContextInformationSubscriptionApi query_subscription GET /subscriptions Retrieve list of Subscriptions
ContextInformationSubscriptionApi retrieve_subscription GET /subscriptions/{subscriptionId} Subscription retrieval by id
ContextInformationSubscriptionApi update_subscription PATCH /subscriptions/{subscriptionId} Subscription update by id
ContextSourceDiscoveryApi query_csr GET /csourceRegistrations Discover Csource registrations
ContextSourceDiscoveryApi retrieve_csr GET /csourceRegistrations/{registrationId} Csource registration retrieval by id
ContextSourceRegistrationApi create_csr POST /csourceRegistrations Csource registration creation
ContextSourceRegistrationApi delete_csr DELETE /csourceRegistrations/{registrationId} Csource registration deletion by id
ContextSourceRegistrationApi update_csr PATCH /csourceRegistrations/{registrationId} Csource registration update by id
ContextSourceRegistrationSubscriptionApi create_csr_subscription POST /csourceSubscriptions Create subscription to Csource registration
ContextSourceRegistrationSubscriptionApi delete_csr_subscription DELETE /csourceSubscriptions/{subscriptionId} Csource registration subscription deletion by id
ContextSourceRegistrationSubscriptionApi query_csr_subscription GET /csourceSubscriptions Retrieval of list of subscriptions to Csource registrations
ContextSourceRegistrationSubscriptionApi retrieve_csr_subscription GET /csourceSubscriptions/{subscriptionId} Csource registration subscription update by id
ContextSourceRegistrationSubscriptionApi update_csr_subscription PATCH /csourceSubscriptions/{subscriptionId} Csource registration subscription update by id
JSONLDContextAPIApi create_context POST /jsonldContexts Add a user @context to the internal cache
JSONLDContextAPIApi delete_context DELETE /jsonldContexts/{contextId} Delete one specific @context from internal cache, possibly re-inserting a freshly downloaded copy of it
JSONLDContextAPIApi list_contexts GET /jsonldContexts List all cached @contexts
JSONLDContextAPIApi retrieve_context GET /jsonldContexts/{contextId} Serve one specific user @context
TemporalContextInformationConsumptionApi query_temporal GET /temporal/entities Query temporal evolution of Entities
TemporalContextInformationConsumptionApi retrieve_temporal GET /temporal/entities/{entityId} Temporal Representation of Entity retrieval by id
TemporalContextInformationConsumptionApi temporal_query_batch POST /temporal/entityOperations/query Temporal Representation of Entity Query based on POST
TemporalContextInformationProvisionApi append_attrs_temporal POST /temporal/entities/{entityId}/attrs Temporal Representation of Entity Attribute instance addition
TemporalContextInformationProvisionApi delete_attr_instance_temporal DELETE /temporal/entities/{entityId}/attrs/{attrId}/{instanceId} Attribute Instance deletion by instance id
TemporalContextInformationProvisionApi delete_attrs_temporal DELETE /temporal/entities/{entityId}/attrs/{attrId} Attribute from Temporal Representation of Entity deletion
TemporalContextInformationProvisionApi delete_temporal DELETE /temporal/entities/{entityId} Temporal Representation of Entity deletion by id
TemporalContextInformationProvisionApi update_attrs_temporal PATCH /temporal/entities/{entityId}/attrs/{attrId}/{instanceId} Attribute Instance update
TemporalContextInformationProvisionApi upsert_temporal POST /temporal/entities Temporal Representation of Entity creation

Documentation For Models

Documentation For Authorization

Endpoints do not require authorization.

Author

About

A Python-based NGSI-LD API client generated from its OpenAPI specification.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages