streamsx.rest_primitives module

class streamsx.rest_primitives.ActiveService(json_rep, rest_client)

Bases: streamsx.rest_primitives._ResourceElement

The ActiveService element resource provides access to information about a 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)

Bases: object

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)

Bases: streamsx.rest_primitives._ResourceElement

The domain element resource provides access to information about a Streams domain.

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)

Bases: streamsx.rest_primitives._ResourceElement

Exported stream resource represents a stream that has been exported 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)

Bases: streamsx.rest_primitives._ResourceElement

The host element resource provides access to information about a host that is allocated to a domain as a resource for running Streams services and applications.

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)

Bases: streamsx.rest_primitives._ResourceElement

Imported stream resource represents a stream that has been 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)

Bases: streamsx.rest_primitives._ResourceElement

The Installation element resource provides access to information about IBM Streams installations.

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)

Bases: streamsx.rest_primitives._ResourceElement

The instance element resource provides access to information about a 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)
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()

Get the list of Operator elements associated with this instance.

Returns:List of Operator elements associated with this instance.
Return type:list(Operator)
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)

refresh()

Refresh the resource and update the attributes to reflect the latest status.

class streamsx.rest_primitives.Job(json_rep, rest_client)

Bases: streamsx.rest_primitives._ResourceElement

The job element resource provides access to information about a submitted job within a specified instance.

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()

Get the list of Operator elements associated with this job.

Returns:List of Operator elements associated with this job.
Return type:list(Operator)
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)

refresh()

Refresh the resource and update the attributes to reflect the latest status.

class streamsx.rest_primitives.Metric(json_rep, rest_client)

Bases: streamsx.rest_primitives._ResourceElement

Metric resource provides access to information about a Streams 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)

Bases: streamsx.rest_primitives._ResourceElement

The operator element resource provides access to information about a specific operator in 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_metrics(name=None)

Get metrics for an 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)
refresh()

Refresh the resource and update the attributes to reflect the latest status.

class streamsx.rest_primitives.OperatorConnection(json_rep, rest_client)

Bases: streamsx.rest_primitives._ResourceElement

The operator connection element resource provides access to information about a connection between two operator ports.

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.OperatorOutputPort(json_rep, rest_client)

Bases: streamsx.rest_primitives._ResourceElement

Operator output port resource provides access to information about an output port for a specific operator.

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
refresh()

Refresh the resource and update the attributes to reflect the latest status.

class streamsx.rest_primitives.PE(json_rep, rest_client)

Bases: streamsx.rest_primitives._ResourceElement

The processing element (PE) resource provides access to information about a PE.

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
refresh()

Refresh the resource and update the attributes to reflect the latest status.

class streamsx.rest_primitives.PEConnection(json_rep, rest_client)

Bases: streamsx.rest_primitives._ResourceElement

The processing element (PE) connection resource provides access to information about a connection between two processing element (PE) ports.

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)

Bases: object

Metadata for a published topic.

topic

str – Published topic

schema

str – Schema of topic

class streamsx.rest_primitives.Resource(json_rep, rest_client)

Bases: streamsx.rest_primitives._ResourceElement

The Streams resource element provides access to information about a Streams resource.

name

str – Resource name.

get_resource()
refresh()

Refresh the resource and update the attributes to reflect the latest status.

class streamsx.rest_primitives.ResourceAllocation(json_rep, rest_client)

Bases: streamsx.rest_primitives._ResourceElement

The ResourceAllocation element resource provides access to information about 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
refresh()

Refresh the resource and update the attributes to reflect the latest status.

class streamsx.rest_primitives.ResourceTag(json_resource_tag)

Bases: object

Contains information for a tag that is 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.StreamingAnalyticsService(rest_client, credentials)

Bases: object

Streaming Analytics service running on IBM Bluemix cloud platform.

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 stop operation.
Return type:dict
class streamsx.rest_primitives.View(json_view, rest_client)

Bases: streamsx.rest_primitives._ResourceElement

The View resource element provides access to information about a view that is associated with an active job, and exposes methods to retrieve data from the view’s 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)

Bases: streamsx.rest_primitives._ResourceElement

Represents the data of a tuple, its type, and the time when it was collected from the stream.

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.

streamsx.rest_primitives.get_view_obj(_view, rc)