Inheritance diagram for fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine:
Collaboration diagram for fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine:
Public Member Functions | |
| __init__ (self, settings={}) | |
| Constructor for CloudRequestEngine. | |
| add_requested_properties (self, names) | |
| Add to the properties each request asks for, after the engine is built. | |
| check_credentials (self) | |
| Refuse a combination of resource key, licence key and requested properties that the cloud service would refuse on every request, so a deployment sees one configuration error when the engine is built rather than a failure on every request it serves. | |
| get_credentials (self) | |
| The credentials to send with a request, as the keys the cloud service reads them from. | |
| flow_element_properties (self) | |
| evidence_keys (self) | |
| get_evidence_keys (self) | |
| Internal function for getting evidence keys used by cloud engines @rtype: dict. | |
| get_evidence_key_filter (self) | |
| Instance of EvidenceKeyFilter based on the evidence keys fetched from the cloud service by the private getEvidenceKeys() method. | |
| get_engine_properties (self) | |
| Internal method to get properties for cloud engines from the cloud service. | |
| validate_response (self, requests.Response cloud_response, check_for_error_messages=True) | |
| Validate the JSON response from the cloud service. | |
| make_cloud_request (self, type, url, content=None) | |
| @type url: string | |
| process_internal (self, flowdata) | |
| Processing function for the CloudRequestEngine Makes a request to the cloud service with the supplied resource key and evidence and returns a JSON object that is then parsed by cloud engines placed later in the pipeline. | |
| report_properties_not_covered (self, result) | |
| Compare the properties a request asked for with the ones its answer carries, and warn once about any it left out. | |
| get_content (self, flowData) | |
| Generate the Content to send in the POST request. | |
| add_query_data (self, query_data, all_evidence, evidence) | |
| Add query data to the evidence. | |
| get_selected_evidence (self, evidence, type) | |
| Get evidence with specified prefix. | |
| key_has_prefix (self, itemKey, prefix) | |
| Check that the key of a KeyValuePair has the given prefix. | |
Public Member Functions inherited from fiftyone_pipeline_engines.engine.Engine | |
| __init__ (self, data_file=None) | |
| Constructor for an engine. | |
| set_cache (self, cache) | |
| Add a cache to an engine @type cashe: Cache. | |
| set_restricted_properties (self, properties_list) | |
| Add a subset of properties. | |
| in_cache (self, flowdata) | |
| A method to check if a flowdata's evidence is in the cache. | |
| refresh (self, identifier) | |
| process (self, flowdata) | |
| Engine's core process function. | |
| on_registration (self, pipeline) | |
| Called when an engine is registered with a pipeline and if there is a data file, a data file update service is attached to the parent pipeline. | |
| close (self) | |
| Stop the checks and updates of the engine's data file, whose timers would otherwise keep the engine alive. | |
| register_data_file (self, data_file) | |
| Register a data_file of the DataFile class with the engine @type data_file: DataFile. | |
Public Member Functions inherited from fiftyone_pipeline_core.flowelement.FlowElement | |
| __init__ (self) | |
| List of Pipelines the FlowElement has been added to. | |
| filter_evidence (self, flowdata) | |
| Filter FlowData evidence using the FlowElement's EvidenceKeyFilter. | |
| filter_evidence_key (self, key) | |
| Filter FlowData.evidence using the flowElement's EvidenceKeyFilter with the property key of evidence of interest. | |
| get_properties (self) | |
| Get the FlowElement.properties of a FlowElement. | |
Static Public Member Functions | |
| setting_text (settings, name) | |
| A setting as trimmed text, or an empty string when it is missing, None or only whitespace. | |
| setting_names (settings, name) | |
| A setting holding property names, as a list of trimmed, non-empty, lower-cased names. | |
Public Attributes | |
| resource_key = self.setting_text(settings, "resource_key") | |
| str | license_key = self.setting_text(settings, "license_key") |
| requested_properties | |
| reported_not_covered = set() | |
| str | baseURL = settings["cloud_endpoint"] |
| http_client = settings["http_client"] | |
| cloud_request_origin = settings["cloud_request_origin"] | |
| evidence_keys | |
Public Attributes inherited from fiftyone_pipeline_engines.engine.Engine | |
| data_file = data_file | |
| cache = cache | |
| restricted_properties = properties_list | |
Public Attributes inherited from fiftyone_pipeline_core.flowelement.FlowElement | |
| list | pipelines = [] |
| dict | properties = {} |
| str | datakey = "" |
| bool | exclude_from_messages = False |
Additional Inherited Members | |
Protected Member Functions inherited from fiftyone_pipeline_core.flowelement.FlowElement | |
| _log (self, level, message) | |
Constructor & Destructor Documentation
◆ __init__()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.__init__ | ( | self, | |
| settings = {} ) |
Constructor for CloudRequestEngine.
@type settings: dict
- Parameters
-
settings Settings should contain a resource_key or a license_key, and optionally 1) requested_properties, the fully qualified names of the properties to ask for, as a list or a comma separated string. Required with a license_key alone and refused with a resource_key, because the cloud service ignores the list whenever a resource key is present 2) a cloud_endpoint to overwrite the default baseurl 3) an cloud_request_origin to use when making requests
See the Credentials section of the cloud request engine specification for the combinations that are accepted: https://github.com/51Degrees/specifications/blob/main/pipeline-specification/pipeline-elements/cloud-request-engine.md#credentials
Member Function Documentation
◆ add_query_data()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.add_query_data | ( | self, | |
| query_data, | |||
| all_evidence, | |||
| evidence ) |
Add query data to the evidence.
- Parameters
-
query_data: The destination dictionary to add query data to. all_evidence All evidence in the flow data. This is used to report which evidence keys are conflicting. evidence Evidence to add to the query Data.
◆ add_requested_properties()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.add_requested_properties | ( | self, | |
| names ) |
Add to the properties each request asks for, after the engine is built.
The names are trimmed and lower-cased as the constructor does, so a name given in the case the documentation uses still matches the answer, and the credential rules are checked again, because a list only has meaning on a licence key alone and the constructor's check cannot see a list added later.
@type names: list or string
- Parameters
-
names the names to add, as a list or one comma separated string, each as "section.property"
◆ check_credentials()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.check_credentials | ( | self | ) |
Refuse a combination of resource key, licence key and requested properties that the cloud service would refuse on every request, so a deployment sees one configuration error when the engine is built rather than a failure on every request it serves.
◆ evidence_keys()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.evidence_keys | ( | self | ) |
◆ flow_element_properties()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.flow_element_properties | ( | self | ) |
◆ get_content()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.get_content | ( | self, | |
| flowData ) |
Generate the Content to send in the POST request.
The evidence keys e.g. 'query.' and 'header.' have an order of precedence. These are added to the evidence in reverse order, if there is conflict then the queryData value is overwritten.
'query.' evidence should take precedence over all other evidence. If there are evidence keys other than 'query.' that conflict then this is unexpected so a warning will be logged.
- Parameters
-
flowData: FlowData
- Returns
- : Evidence Dictionary
◆ get_credentials()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.get_credentials | ( | self | ) |
The credentials to send with a request, as the keys the cloud service reads them from.
A key that is not set is left out.
@rtype: dict
- Returns
- : Returns the credentials to send
◆ get_engine_properties()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.get_engine_properties | ( | self | ) |
Internal method to get properties for cloud engines from the cloud service.
@rtype: dict
- Returns
- : Returns properties for all engines
◆ get_evidence_key_filter()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.get_evidence_key_filter | ( | self | ) |
Instance of EvidenceKeyFilter based on the evidence keys fetched from the cloud service by the private getEvidenceKeys() method.
@type: BasicListEvidenceKeyFilter
- Returns
- : Returns BasicListEvidenceKeyFilter
Reimplemented from fiftyone_pipeline_core.flowelement.FlowElement.
◆ get_evidence_keys()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.get_evidence_keys | ( | self | ) |
Internal function for getting evidence keys used by cloud engines @rtype: dict.
- Returns
- : Returns list of keys
◆ get_selected_evidence()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.get_selected_evidence | ( | self, | |
| evidence, | |||
| type ) |
Get evidence with specified prefix.
- Parameters
-
evidence All evidence in the flow data. type Required evidence key prefix
◆ key_has_prefix()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.key_has_prefix | ( | self, | |
| itemKey, | |||
| prefix ) |
Check that the key of a KeyValuePair has the given prefix.
- Parameters
-
itemKey Key to check prefix The prefix to check for.
- Returns
- : True if the key has the prefix.
◆ make_cloud_request()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.make_cloud_request | ( | self, | |
| type, | |||
| url, | |||
| content = None ) |
@type url: string
- Parameters
-
url
@rtype: dict
- Returns
- Returns dict with data and error properties error contains any errors from the request, data contains the response
◆ process_internal()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.process_internal | ( | self, | |
| flowdata ) |
Processing function for the CloudRequestEngine Makes a request to the cloud service with the supplied resource key and evidence and returns a JSON object that is then parsed by cloud engines placed later in the pipeline.
@type FlowData: FlowData
- Parameters
-
FlowData Returns a JSON object that is then parsed by cloud engines
Reimplemented from fiftyone_pipeline_core.flowelement.FlowElement.
◆ report_properties_not_covered()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.report_properties_not_covered | ( | self, | |
| result ) |
Compare the properties a request asked for with the ones its answer carries, and warn once about any it left out.
The cloud service drops a property the licence key does not cover without naming it, whenever the request also asked for a property the key does cover, so the engine has to notice the difference itself. A property that is present but null counts as answered, because it carries a nullreason beside it saying why it has no value on this request, which is a different matter from entitlement. The answer cannot change while the key and the list stay the same, so each distinct list is reported once.
@type result: string
- Parameters
-
result the JSON text the cloud service answered with
◆ setting_names()
|
static |
A setting holding property names, as a list of trimmed, non-empty, lower-cased names.
The setting may be a list of names or one comma separated string, and a missing setting gives an empty list.
The names are lower-cased because the cloud service lower-cases property names in its answer, so "Device.IsMobile" comes back as "ismobile" under "device".
◆ setting_text()
|
static |
A setting as trimmed text, or an empty string when it is missing, None or only whitespace.
◆ validate_response()
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.validate_response | ( | self, | |
| requests.Response | cloud_response, | ||
| check_for_error_messages = True ) |
Validate the JSON response from the cloud service.
@type: Response
- Parameters
-
Response returned from the cloud service. @rtype: Exception
- Returns
- : Thrown if there are errors returned from the cloud service.
Member Data Documentation
◆ baseURL
| str fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.baseURL = settings["cloud_endpoint"] |
◆ cloud_request_origin
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.cloud_request_origin = settings["cloud_request_origin"] |
◆ evidence_keys
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.evidence_keys |
◆ http_client
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.http_client = settings["http_client"] |
◆ license_key
| str fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.license_key = self.setting_text(settings, "license_key") |
◆ reported_not_covered
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.reported_not_covered = set() |
◆ requested_properties
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.requested_properties |
◆ resource_key
| fiftyone_pipeline_cloudrequestengine.cloudrequestengine.CloudRequestEngine.resource_key = self.setting_text(settings, "resource_key") |
