streamsx.rest_primitives¶
Primitive objects for REST bindings.
Module contents¶
Functions
get_view_obj |
Classes
ActiveService |
Domain or an instance service. |
ActiveVersion |
Contains IBM Streams installation information |
Domain |
IBM Streams domain. |
ExportedStream |
Stream exported stream by a job. |
Host |
Resource in a Streams domain or instance. |
ImportedStream |
Stream imported by a job. |
Installation |
IBM Streams installation. |
Instance |
IBM Streams instance. |
Job |
A running streams application. |
Metric |
Streams custom or system metric. |
Operator |
An operator invocation within a job. |
OperatorConnection |
Connection between operators. |
OperatorInputPort |
Operator input port. |
OperatorOutputPort |
Operator output port. |
PE |
Processing element (PE) within a job. |
PEConnection |
Stream connection between two PEs. |
PublishedTopic |
Metadata for a published topic. |
Resource |
A resource available to a IBM Streams domain. |
ResourceAllocation |
A resource that is allocated to an IBM Streams instance. |
ResourceTag |
Resource tag defined in a Streams domain |
RestResource |
HTTP REST resource identifier. |
StreamingAnalyticsService |
Streaming Analytics service running on IBM Cloud. |
View |
View on a stream. |
ViewItem |
A stream tuple in view. |
-
class
streamsx.rest_primitives.
ActiveService
(json_rep, rest_client)¶ Domain or an instance service.
-
resourceType
¶ str – Identifies the REST resource type, which is activeService.
-
leader
¶ bool – If True, this service is a standby service.
-
processId
¶ str – Process ID of this service.
-
startTime
¶ long – Epoch time when this service started.
-
status
¶ str – Status of this service. Some possible values include stopped, running, failed, and unknown.
-
type
¶ str – Type of this service.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> services = instances.get_active_services() >>> print(services[0].resourceType) activeService
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
ActiveVersion
(json_active_version)¶ Contains IBM Streams installation information
-
architecture
¶ str – Hardware architecture on which product is installed.
-
build_version
¶ str – Product build ID.
-
edition_name
¶ str – Product edition.
-
full_product_version
¶ str – Full product version, including any hot fix.
-
minimum_os_base_version
¶ str – Minimum operating system version requirement.
-
minimum_os_patch_version
¶ str – Minimum operating system patch requirement.
-
product_name
¶ str – Product name.
-
product_version
¶ str – Product version.
-
-
class
streamsx.rest_primitives.
Domain
(json_rep, rest_client)¶ IBM Streams domain. A domain contains instances that support running Streams applications as jobs.
-
id
¶ str – Unique ID for this domain.
-
resourceType
¶ str – Identifies the REST resource type, which is domain.
-
creationTime
¶ long – Epoch time when this domain was created.
-
creationuser
¶ str – User ID that created this domain.
-
status
¶ str – Status of this domain. Some possible values include running, stopping, stopped, starting, removing, and unknown.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> domains = sc.get_domains() >>> print (domains[0].resourceType) domain
-
get_active_services
()¶ Get the list of
ActiveService
elements associated with this domain.Returns: List of ActiveService elements associated with this domain. Return type: list(ActiveService)
-
get_hosts
()¶ Get the list of
Host
elements associated with this domain.Returns: List of Host elements associated with this domain. Return type: list(Host)
-
get_instances
()¶ Get the list of
Instance
elements associated with this domain.Returns: List of Instance elements associated with this domain. Return type: list(Instance)
-
get_resource_allocations
()¶ Get the list of
ResourceAllocation
elements associated with this domain.Returns: List of ResourceAllocation elements associated with this domain. Return type: list(ResourceAllocation)
-
get_resources
()¶ Get the list of
Resource
elements associated with this domain.Returns: List of Resource elements associated with this domain. Return type: list(Resource)
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
ExportedStream
(json_rep, rest_client)¶ Stream exported stream by a job.
-
resourceType
¶ str – Identifies the REST resource type, which is exportedStream.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> exportedstreams = instances[0].get_exported_streams() >>> print (exportedstreams[0].resourceType) exportedStream
-
get_operator_output_port
()¶ Get the output port of this exported stream.
Returns: Output port of this exported stream. Return type: OperatorOutputPort
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
Host
(json_rep, rest_client)¶ Resource in a Streams domain or instance.
-
name
¶ str – Configuration name for the IBM Streams resource.
-
resourceType
¶ str – Identifies the REST resource type, which is host.
-
ipAddress
¶ str – IP address for the IBM Streams resource.
-
processorCount
¶ int – Number of processors on the IBM Streams resource.
-
restrictedTags
¶ list(str) – Set of resource tags that processing elements (PEs) must have to run on the IBM Streams resource.
-
services
¶ list(dict) – Name and status of each domain service that is designated to run on the IBM Streams resource.
-
status
¶ str – Status of the IBM Streams resource.
-
tag
¶ list(str) – Names of each tag that is assigned to the IBM Streams resource.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> domains = sc.get_domains() >>> hosts = domains[0].get_hosts() >>> print (hosts[0].resourceType) host
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
ImportedStream
(json_rep, rest_client)¶ Stream imported by a job.
-
resourceType
¶ str – Identifies the REST resource type, which is importedStream.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> importedstreams = instances[0].get_imported_streams() >>> print (importedstreams[0].resourceType) importedStream
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
Installation
(json_rep, rest_client)¶ IBM Streams installation.
-
resourceType
¶ str – Identifies the REST resource type, which is installation.
-
architecture
¶ str – Hardware architecture on which product is installed.
-
buildVersion
¶ str – Product build ID.
-
editionName
¶ str – Product edition.
-
fullProductVersion
¶ str – Full product version, including any hot fix.
-
minimumOSBaseVersion
¶ str – Minimum operating system version requirement.
-
minimumOSPatchVersion
¶ str – Minimum operating system patch requirement.
-
productName
¶ str – Product name.
-
productVersion
¶ str – Product version.
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
Instance
(json_rep, rest_client)¶ IBM Streams instance.
-
id
¶ str – Unique ID for this instance.
-
resourceType
¶ str – Identifies the REST resource type, which is instance.
-
creationTime
¶ long – Epoch time when this instance was created.
-
creationuser
¶ str – User ID that created this instance.
-
health
¶ str – Summarize status of the jobs in the instance. Some possible values include healthy, partiallyHealthy, partiallyUnhealthy, unhealthy, and unknown.
-
owner
¶ str – User ID that owns this instance.
-
startTime
¶ long – Epoch time when this instance was started.
-
status
¶ str – Status of this instance. Some possible values include running, failed, stopped, and unknown.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> print (instances[0].resourceType) instance
-
get_active_services
()¶ Get the list of
ActiveService
elements associated with this instance.Returns: List of ActiveService elements associated with this instance. Return type: list(ActiveService)
-
get_domain
()¶ Get the Streams domain that owns this instance.
Returns: Streams domain owning this instance. Return type: Domain
-
get_exported_streams
()¶ Get the list of
ExportedStream
elements associated with this instance.Returns: List of ExportedStream elements associated with this instance. Return type: list(ExportedStream)
-
get_hosts
()¶ Get the list of
Host
element associated with this instance.Returns: List of Host element associated with this instance. Return type: list(Host)
-
get_imported_streams
()¶ Get the list of
ImportedStream
elements associated with this instance.Returns: List of ImportedStream elements associated with this instance. Return type: list(ImportedStream)
-
get_job
(id)¶ Retrieves a job matching the given id
Parameters: id (str) – Job id to match. Returns: Job matching the given id Return type: Job Raises: ValueError
– No resource matches given id or multiple resources matching given id
-
get_jobs
(name=None)¶ Retrieves jobs running in this instance.
Parameters: name (str, optional) – Only return jobs containing property name that matches name. name can be a regular expression. If name is not supplied, then all jobs are returned. Returns: A list of jobs matching the given name. Return type: list(Job) Retrieving a list of jobs whose name contains the string “temperatureSensor” could be performed as followed .. rubric:: Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instance = sc.get_instances()[0] >>> jobs = instance.get_jobs(name="*temperatureApplication*")
-
get_operator_connections
()¶ Get the list of
OperatorConnection
elements associated with this instance.Returns: List of OperatorConnection elements associated with this instance. Return type: list(OperatorConnection)
-
get_operators
(name=None)¶ Get the list of
Operator
elements associated with this instance.Parameters: name (str) – Only return operators matching name, where name can be a regular expression. If name is not supplied, then all operators for this instance are returned. Returns: List of Operator elements associated with this instance. Return type: list(Operator) Retrieving a list of operators whose name contains the string “temperatureSensor” could be performed as followed .. rubric:: Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instance = sc.get_instances()[0] >>> operators = instance.get_operators(name="*temperatureSensor*")
-
get_pe_connections
()¶ Get the list of
PEConnection
elements associated with this instance.Returns: List of PEConnection elements associated with this instance. Return type: list(PEConnection)
-
get_pes
()¶ Get the list of
PE
elements associated with this instance resource.Returns: List of PE elements associated with this instance. Return type: list(PE)
-
get_published_topics
()¶ Get a list of published topics for this instance.
Streams applications publish streams to a a topic that can be subscribed to by other applications. This allows a microservice approach where publishers and subscribers are independent of each other.
A published stream has a topic and a schema. It is recommended that a topic is only associated with a single schema.
Streams may be published and subscribed by applications regardless of the implementation language. For example a Python application can publish a stream of JSON tuples that are subscribed to by SPL and Java applications.
Returns: List of currently published topics. Return type: list(PublishedTopic)
-
get_resource_allocations
()¶ Get the list of
ResourceAllocation
elements associated with this instance.Returns: List of ResourceAllocation elements associated with this instance. Return type: list(ResourceAllocation)
-
get_views
(name=None)¶ Get the list of
View
elements associated with this instance.Parameters: - name (str, optional) – Returns view(s) matching name. name can be a regular expression. If name
- not supplied, then all views associated with this instance are returned. (is) –
Returns: List of views matching name.
Return type: list(View)
Retrieving a list of views whose name contains the string “temperatureSensor” could be performed as followed .. rubric:: Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instance = sc.get_instances()[0] >>> view = instance.get_views(name="*temperatureSensor*")
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
Job
(json_rep, rest_client)¶ A running streams application.
-
id
¶ str – job ID.
-
name
¶ str – Name of the job.
-
resourceType
¶ str – Identifies the REST resource type, which is job.
-
health
¶ str – Health indicator for the job. Some possible values for this property include healthy, partiallyHealthy, partiallyUnhealthy, unhealthy, and unknown.
-
applicationName
¶ str – Name of the streams processing application that this job is running.
-
jobGroup
¶ str – Identifies the job group to which this job belongs.
-
startedBy
¶ str – Identifies the user ID that started this job.
-
status
¶ str – Status of this job. Some possible values for this property include canceling, running, canceled, and unknown.
-
submitTime
¶ long – Epoch time when this job was submitted.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> jobs = instances[0].get_jobs() >>> print (jobs[0].health) healthy
-
cancel
(force=False)¶ Cancel this job.
Parameters: force (bool, optional) – Forcefully cancel this job. Returns: True if the job was cancelled, otherwise False if an error occurred. Return type: bool
-
get_domain
()¶ Get the Streams domain that owns this job.
Returns: Streams domain that owns this job. Return type: Domain
-
get_hosts
()¶ Get the list of
Host
elements associated with this job.Returns: List of Host elements associated with this job. Return type: list(Host)
-
get_instance
()¶ Get the Streams instance that owns this job.
Returns: Streams instance that owns this job. Return type: Instance
-
get_operator_connections
()¶ Get the list of
OperatorConnection
elements associated with this job.Returns: List of OperatorConnection elements associated with this job. Return type: list(OperatorConnection)
-
get_operators
(name=None)¶ Get the list of
Operator
elements associated with this job.Parameters: name (str) – Only return operators matching name, where name can be a regular expression. If name is not supplied, then all operators for this job are returned. Returns: List of Operator elements associated with this job. Return type: list(Operator) Retrieving a list of operators whose name contains the string “temperatureSensor” could be performed as followed .. rubric:: Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> job = instances[0].get_jobs()[0] >>> operators = job.get_operators(name="*temperatureSensor*")
-
get_pe_connections
()¶ Get the list of
PEConnection
elements associated with this job.Returns: List of PEConnection elements associated with this job. Return type: list(PEConnection)
-
get_pes
()¶ Get the list of
PE
elements associated with this job.Returns: List of PE elements associated with this job. Return type: list(PE)
-
get_resource_allocations
()¶ Get the list of
ResourceAllocation
elements associated with this job.Returns: List of ResourceAllocation elements associated with this job. Return type: list(ResourceAllocation)
-
get_views
(name=None)¶ Get the list of
View
elements associated with this job.Parameters: - name (str, optional) – Returns view(s) matching name. name can be a regular expression. If name
- not supplied, then all views associated with this instance are returned. (is) –
Returns: List of views matching name.
Return type: list(View)
Retrieving a list of views that contain the string “temperatureSensor” could be performed as followed .. rubric:: Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> job = instances[0].get_jobs()[0] >>> views = job.get_views(name = "*temperatureSensor*")
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
retrieve_log_trace
(filename=None, dir=None)¶ Retrieves the application log and trace files of the job and saves them as a compressed tar file.
An existing file with the same name will be overwritten.
Parameters: - filename (str) – name of the created tar file. Defaults to job_<id>_<timestamp>.tar.gz where id is the job identifier and timestamp is the number of seconds since the Unix epoch, for example
job_355_1511995995.tar.gz
. - dir (str) – a valid directory in which to save the archive. Defaults to the current directory.
Returns: the path to the created tar file, or None if retrieving a job’s logs is not supported in the version of streams to which the job is submitted.
Return type: str
New in version 1.8.
- filename (str) – name of the created tar file. Defaults to job_<id>_<timestamp>.tar.gz where id is the job identifier and timestamp is the number of seconds since the Unix epoch, for example
-
-
class
streamsx.rest_primitives.
Metric
(json_rep, rest_client)¶ Streams custom or system metric.
-
name
¶ str – Name of this metric.
-
resourceType
¶ str – Identifies the REST resource type, which is metric.
-
description
¶ str – Describes this metric.
-
lastTimeRetrieved
¶ str – Epoch time when the metric was most recently retrieved.
-
metricKind
¶ str – Kind of metric. Some possible values include counter, gauge, time and unknown.
-
metricType
¶ str – Type of metric. Some possible values include system, custom and unknown.
-
value
¶ int – Value for the metric.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> operators = instances[0].get_operators() >>> metrics = operators[0].get_metrics() >>> print (metrics[0].resourceType) metric
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
Operator
(json_rep, rest_client)¶ An operator invocation within a job.
-
name
¶ str – Operator name.
-
resourceType
¶ str – Identifies the REST resource type, which is operator.
-
operatorKind
¶ str – SPL primitive operator type for this operator.
-
indexWithinJob
¶ int – Index of this operator within the job.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> operators = instances[0].get_operators() >>> print (operators[0].resourceType) operator
-
get_host
()¶ - Get resource this operator is currently executing in.
- If the operator is running on an externally
managed resource
None
is returned.
Returns: Resource this operator is running on. Return type: Host New in version 1.9.
-
get_input_ports
()¶ Get list of input ports for this operator.
Returns: Input ports for this operator. Return type: list(OperatorInputPort) New in version 1.9.
-
get_metrics
(name=None)¶ Get metrics for this operator.
Parameters: name (str, optional) – Only return metrics matching name, where name can be a regular expression. If name is not supplied, then all metrics for this operator are returned. Returns: List of matching metrics. Return type: list(Metric) Retrieving a list of metrics whose name contains the string “temperatureSensor” could be performed as followed .. rubric:: Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> operator = instances[0].get_operators()[0] >>> metrics = op.get_metrics(name='*temperatureSensor*')
-
get_output_ports
()¶ Get list of output ports for this operator.
Returns: Output ports for this operator. Return type: list(OperatorOutputPort) New in version 1.9.
-
get_pe
()¶ Get the Streams processing element this operator is executing in.
Returns: Processing element for this operator. Return type: PE New in version 1.9.
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
OperatorConnection
(json_rep, rest_client)¶ Connection between operators.
-
id
¶ str – Unique ID of this operator connection within the instance.
-
resourceType
¶ str – Identifies the REST resource type, which is operator.
-
required
¶ bool – Indicates whether the connection is required.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> operatorconnections = instances[0].get_operator_connections() >>> print (operatorconnections[0].resourceType) operatorConnection
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
OperatorInputPort
(json_rep, rest_client)¶ Operator input port.
-
name
¶ str – Name of this input port.
-
resourceType
¶ str – Identifies the REST resource type, which is operatorInputPort.
-
indexWithinOperator
¶ int – Index of the input port within the operator.
New in version 1.9.
-
get_metrics
(name=None)¶ Get metrics for this input port.
Parameters: name (str, optional) – Only return metrics matching name, where name can be a regular expression. If name is not supplied, then all metrics for this input port are returned. Returns: List of matching metrics. Return type: list(Metric) Retrieving a list of metrics whose name contains the string “temperatureSensor” could be performed as followed .. rubric:: Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> operator = instances[0].get_operators()[0] >>> input_port = operator.get_input_ports()[0] >>> metrics = input_port.get_metrics(name='*temperatureSensor*')
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
OperatorOutputPort
(json_rep, rest_client)¶ Operator output port.
-
name
¶ str – Name of this output port.
-
resourceType
¶ str – Identifies the REST resource type, which is operatorOutputPort.
-
indexWithinOperator
¶ int – Index of the output port within the operator.
-
streamName
¶ str – Name of the stream that is associated with this output port.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> exportedstreams = instances[0].get_exported_streams() >>> operatoroutputport = exportedstreams[0].get_operator_output_port() >>> print (operatoroutputport.resourceType) operatorOutputPort
-
get_metrics
(name=None)¶ Get metrics for this output port.
Parameters: name (str, optional) – Only return metrics matching name, where name can be a regular expression. If name is not supplied, then all metrics for this output port are returned. Returns: List of matching metrics. Return type: list(Metric) Retrieving a list of metrics whose name contains the string “temperatureSensor” could be performed as followed .. rubric:: Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> exportedstreams = instances[0].get_exported_streams() >>> operatoroutputport = exportedstreams[0].get_operator_output_port() >>> operatoroutputport.get_metrics(name='*temperatureSensor*')
New in version 1.9.
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
PE
(json_rep, rest_client)¶ Processing element (PE) within a job. A processing element hosts one or more operators within a single job.
-
id
¶ str – PE ID.
-
resourceType
¶ str – Identifies the REST resource type, which is pe.
-
health
¶ str – Health indicator for this PE. Some possible values include healthy, partiallyHealthy, partiallyUnhealthy, unhealthy, and unknown.
-
indexWithinJob
¶ int – Index of the PE within the job.
-
launchCount
¶ int – Number of times this PE was started manually or automatically because of failures.
-
optionalConnections
¶ str – Status of optional connections for this PE. Some possible values include connected, disconnected, partiallyConnected, and unknown.
-
pendingTracingLevel
¶ str – Describes a pending change to the granularity of the trace information that is stored for this PE. Some possible values include off, error, debug and trace. The value is None, if no change is pending.
-
processId
¶ str – Operating system process ID for this PE.
-
relocatable
¶ bool – Indicates whether this PE can be relocated to a different resource.
-
requiredConnections
¶ str – Status of the required connections for this PE. Some possible values include connected, disconnected, partiallyConnected, and unknown.
-
restartable
¶ bool – Indicates whether this PE can be restarted.
-
status
¶ str – Status of this PE.
-
statusReason
¶ str – Additional information for the status of this PE.
-
tracingLevel
¶ str – Granularity of the trace information. Some possible values include off, error, debug and trace.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> pes = instances.get_pes() >>> print(pes[0].resourceType) pe
-
get_host
()¶ - Get resource this processing element is currently executing in.
- If the processing element is running on an externally
managed resource
None
is returned.
Returns: Resource this processing element is running on. Return type: Host New in version 1.9.
-
get_metrics
(name=None)¶ Get metrics for this PE.
Parameters: name (str, optional) – Only return metrics matching name, where name can be a regular expression. If name is not supplied, then all metrics for this PE are returned. Returns: List of matching metrics. Return type: list(Metric) Retrieving a list of metrics whose name contains the string “temperatureSensor” could be performed as followed .. rubric:: Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> pe = instances.get_pes()[0] >>> metrics = pe.get_metrics(name='*temperatureSensor*')
New in version 1.9.
-
get_resource_allocation
()¶ Get the
ResourceAllocation
element tance.Returns: Resource allocation used to access information about the resource where this PE is running. Return type: ResourceAllocation New in version 1.9.
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
retrieve_console_log
(filename=None, dir=None)¶ Retrieves the application console log (standard out and error) files for this PE and saves them as a plain text file.
An existing file with the same name will be overwritten.
Parameters: - filename (str) – name of the created file. Defaults to pe_<id>_<timestamp>.stdouterr where id is the PE identifier and timestamp is the number of seconds since the Unix epoch, for example
pe_83_1511995995.trace
. - dir (str) – a valid directory in which to save the file. Defaults to the current directory.
Returns: the path to the created file, or None if retrieving a job’s logs is not supported in the version of streams to which the job is submitted.
Return type: str
New in version 1.9.
- filename (str) – name of the created file. Defaults to pe_<id>_<timestamp>.stdouterr where id is the PE identifier and timestamp is the number of seconds since the Unix epoch, for example
-
retrieve_trace
(filename=None, dir=None)¶ Retrieves the application trace files for this PE and saves them as a plain text file.
An existing file with the same name will be overwritten.
Parameters: - filename (str) – name of the created file. Defaults to pe_<id>_<timestamp>.trace where id is the PE identifier and timestamp is the number of seconds since the Unix epoch, for example
pe_83_1511995995.trace
. - dir (str) – a valid directory in which to save the file. Defaults to the current directory.
Returns: the path to the created file, or None if retrieving a job’s logs is not supported in the version of streams to which the job is submitted.
Return type: str
New in version 1.9.
- filename (str) – name of the created file. Defaults to pe_<id>_<timestamp>.trace where id is the PE identifier and timestamp is the number of seconds since the Unix epoch, for example
-
-
class
streamsx.rest_primitives.
PEConnection
(json_rep, rest_client)¶ Stream connection between two PEs.
-
id
¶ str – PE connection ID.
-
resourceType
¶ str – Identifies the REST resource type, which is peConnection.
-
required
¶ bool – Indicates whether this connection is required.
-
status
¶ str – Status of this connection. Some possible values include connected, disconnected, and unknown.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> peconnections = instances.get_pe_connections() >>> print(peconnections[0].resourceType) peConnection
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
PublishedTopic
(topic, schema)¶ Metadata for a published topic.
-
topic
¶ str – Published topic
-
schema
¶ str – Schema of topic
-
-
class
streamsx.rest_primitives.
Resource
(json_rep, rest_client)¶ A resource available to a IBM Streams domain.
-
id
¶ str – Resource identifier.
-
displayName
¶ str – Resource display name.
-
ipAddress
¶ str – IP address.
-
status
¶ str – Resource status.
list[str] – Tags assigned to resource.
New in version 1.9.
-
get_metrics
(name=None)¶ Get metrics for this resource.
Parameters: name (str, optional) – Only return metrics matching name, where name can be a regular expression. If name is not supplied, then all metrics for this resource are returned. Returns: List of matching metrics. Return type: list(Metric)
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
ResourceAllocation
(json_rep, rest_client)¶ A resource that is allocated to an IBM Streams instance.
-
resourceType
¶ str – Identifies the REST resource type, which is resourceAllocation.
-
applicationResource
¶ bool – Indicates whether this resource is an application resource, which is used to run streams processing applications.
-
schedulerStatus
¶ str – Indicates whether this resource is schedulable for the instance.
-
status
¶ str – Status of this resource for the instance.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> allocations = instances.get_resource_allocations() >>> print(allocations[0].resourceType) resourceAllocation
-
get_jobs
(name=None)¶ Retrieves jobs running on this resource in its instance.
Parameters: name (str, optional) – Only return jobs containing property name that matches name. name can be a regular expression. If name is not supplied, then all jobs are returned. Returns: A list of jobs matching the given name. Return type: list(Job) Note
If
applicationResource
is False an empty list is returned.New in version 1.9.
-
get_pes
()¶ Get the list of
PE
running on this resource in its instance.Returns: List of PE running on this resource. Return type: list(PE) Note
If
applicationResource
is False an empty list is returned.New in version 1.9.
-
get_resource
()¶ Get the
Resource
of the resource allocation.Returns: Resource for this allocation. Return type: Resource New in version 1.9.
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
ResourceTag
(json_resource_tag)¶ Resource tag defined in a Streams domain
-
definition_format_properties
¶ bool – Indicates whether the resource definition consists of one or more properties.
-
description
¶ str – Tag description.
-
name
¶ str – Tag name.
-
properties_definition
¶ list(str) – Contains the properties of the resource definition. Only present if definition_format_properties is True.
-
reserved
¶ bool – If True, this tag is defined by IBM Streams, and cannot be modified.
-
-
class
streamsx.rest_primitives.
RestResource
(json_rep, rest_client)¶ HTTP REST resource identifier.
-
name
¶ str – Resource name.
-
resource
¶ str – A string that identifies the URI for the resource.
-
get_resource
()¶ Make a request against this REST resource. :returns: JSON response. :rtype: dict
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
-
class
streamsx.rest_primitives.
StreamingAnalyticsService
(rest_client, credentials)¶ Streaming Analytics service running on IBM Cloud.
-
cancel_job
(job_id=None, job_name=None)¶ Cancel a running job.
Parameters: - job_id (str, optional) – Identifier of job to be canceled.
- job_name (str, optional) – Name of job to be canceled.
Returns: JSON response for the job cancel operation.
Return type: dict
-
get_instance_status
()¶ Get the status the instance for this Streaming Analytics service.
Returns: JSON response for the instance status operation. Return type: dict
-
start_instance
()¶ Start the instance for this Streaming Analytics service.
Returns: JSON response for the instance start operation. Return type: dict
-
stop_instance
()¶ Stop the instance for this Streaming Analytics service.
Returns: JSON response for the instance start operation. Return type: dict
-
submit_job
(bundle, job_config=None)¶ Submit a Streams Application Bundle (sab file) to this Streaming Analytics service.
Parameters: - bundle (str) – path to a Streams application bundle (sab file) containing the application to be submitted
- job_config (JobConfig) – a job configuration overlay
Returns: - JSON response from service containing ‘name’ field with unique
job name assigned to submitted job, or, ‘error_status’ and ‘description’ fields if submission was unsuccessful.
Return type: dict
-
-
class
streamsx.rest_primitives.
View
(json_view, rest_client)¶ View on a stream.
-
id
¶ str – An unique identifier for the view.
-
name
¶ str – View name.
-
description
¶ str – Description of the view.
-
resourceType
¶ str – Identifies the REST resource type, which is view.
-
activateOption
¶ str – Indicate when the view starts buffering data.
-
maximumTupleRate
¶ int – Maximum Number of tuples at which the view collects per second.
-
logicalOperatorName
¶ str – The logical name of the operator that contains the output port on which the view is created.
-
bufferCapacitySeconds
¶ int – Buffer size measured in seconds.
-
bufferCapacityTuples
¶ int – Buffer size measured in number of tuples.
-
bufferCapacityUnits
¶ str – Indicates whether the buffer capacity for the view is determined by seconds, tuples or unknown.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> views = instances[0].get_views() >>> print (views[0].resourceType) view
-
get_domain
()¶ Get the Streams domain for the instance that owns this view.
Returns: Streams domain for the instance owning this view. Return type: Domain
-
get_instance
()¶ Get the Streams instance that owns this view.
Returns: Streams instance owning this view. Return type: Instance
-
get_job
()¶ Get the Streams job that owns this view.
Returns: Streams Job owning this view. Return type: Job
-
get_view_items
()¶ Get a list of
ViewItem
elements associated with this view.Returns: List of ViewItem(s) associated with this view. Return type: list(ViewItem)
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-
start_data_fetch
()¶ Starts a thread that fetches data from the Streams view server.
Returns: Queue containing view data. Return type: queue.Queue
-
stop_data_fetch
()¶ Stops the thread that fetches data from the Streams view server.
-
-
class
streamsx.rest_primitives.
ViewItem
(json_rep, rest_client)¶ A stream tuple in view.
-
collectionTime
¶ long – Epoch time when this viewItem is collected from the stream.
-
data
¶ dict – Content of this viewItem.
-
resourceType
¶ str – Identifies the REST resource type, which is viewItem.
Example
>>> from streamsx import rest >>> sc = rest.StreamingAnalyticsConnection() >>> instances = sc.get_instances() >>> views = instances[0].get_views() >>> viewitems = views[0].get_view_items() >>> print (viewitems[0].resourceType) viewItem
-
refresh
()¶ Refresh the resource and update the attributes to reflect the latest status.
-