Created
August 30, 2018 20:01
-
-
Save goneri/c2bb4b14f555072965c1ab9fe0135a87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from dciclient.v1.api import context as dci_context | |
from dciclient.v1.api import job as dci_job | |
from dciclient.v1.api import job as dci_component | |
from dciclient.v1.api import topic as dci_topic | |
class Topic(): | |
def __init__(self, context, topic_name): | |
self._context = context | |
r = dci_topic.list(context, where='name:' + topic_name) | |
self.topic = r.json()['topics'][0] | |
self.id = self.topic['id'] | |
def last_component_id(self): | |
r = dci_topic.list_components(context, self.id) | |
components = r.json()['components'] | |
for component in components: | |
if component['state'] == 'active': | |
return component['id'] | |
return | |
context = dci_context.build_signature_context() | |
osp10 = Topic(context, 'OSP10') | |
osp11 = Topic(context, 'OSP11') | |
osp12 = Topic(context, 'OSP12') | |
osp13 = Topic(context, 'OSP13') | |
osp10_job = dci_job.schedule( | |
context, | |
osp10.id).json()['job'] | |
osp13_job = dci_job.create( | |
context, | |
topic_id=osp13.id, | |
components=[ | |
osp11.last_component_id(), | |
osp12.last_component_id(), | |
osp13.last_component_id(), | |
], | |
# previous_job_id=osp10_job['id'], # The CS does not accept this key | |
) | |
print(osp13_job.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment