MPS サービスを開始すると、システムは自動的に MPS キューを作成します。 API を使用して MPS キューを管理することもできます (パイプライン)。 たとえば、SearchPipelineQueryPipelineListUpdatePipeline などがあります。

MPS キューの検索

SearchPipeline インターフェイスを使用し、MPS キュー情報を検索します。
  1. import json from aliyunsdkmts.request.v20140618 import SearchPipelineRequest from aliyunsdkcore import client region = ‘<region>’ access_key_id = ‘<access_key_id>’ access_key_secret = ‘<access_key_secret>’ client = client.AcsClient(access_key_id, access_key_secret, region) request = SearchPipelineRequest.SearchPipelineRequest() response = client.do_action_with_exception(request); json_response = json.loads(response) pipelines = json_response[‘PipelineList’][‘Pipeline’] for pipeline in pipelines: print pipeline id:’ + pipeline[‘Id’] + ‘, name:’ + pipeline[‘Name’] + ‘, state:’ + pipeline[‘State’]
  1. </section>
  2. <section class="section" id="section-d3q-3nd-z2b">
  3. <h2 class="title sectiontitle" id="h2-url-2">MPS キューの照会</h2>
  4. <div class="p">pipelineId がある場合は、pipelineId を使用して <span class="keyword apiname">QueryPipelineList</span> インターフェイスを呼び出し、MPS のキュー情報を照会します。<pre class="pre codeblock"><code>import json
  5. from aliyunsdkmts.request.v20140618 import QueryPipelineListRequest
  6. from aliyunsdkcore import client
  7. region = '&lt;region&gt;'
  8. access_key_id = '&lt;access_key_id&gt;'
  9. access_key_secret = '&lt;access_key_secret&gt;'
  10. pipeline_id = '&lt;pipeline_id&gt;'
  11. client = client.AcsClient(access_key_id, access_key_secret, region)
  12. request = QueryPipelineListRequest.QueryPipelineListRequest()
  13. request.set_PipelineIds(pipeline_id)
  14. response = client.do_action_with_exception(request);
  15. json_response = json.loads(response)
  16. pipelines = json_response['PipelineList']['Pipeline']
  17. for pipeline in pipelines:
  18. print 'pipeline id:' + pipeline['Id'] + ', name:' + pipeline['Name'] + ', state:' + pipeline['State']</code></pre></div>
  19. </section>
  20. <section class="section" id="section-wx5-knd-z2b">
  21. <h2 class="title sectiontitle" id="h2-url-3">MPS キューの更新</h2>
  22. <div class="p"><span class="keyword apiname">UpdatePipeline</span> インターフェイスを使用して、MPS キューの名前とステータスを含む、MPS キュー情報を更新します。 ステータスは Active および Paused になります。<pre class="pre codeblock"><code>import json
  23. from aliyunsdkmts.request.v20140618 import SearchPipelineRequest
  24. from aliyunsdkmts.request.v20140618 import UpdatePipelineRequest
  25. from aliyunsdkcore import client
  26. region = '&lt;region&gt;'
  27. access_key_id = '&lt;access_key_id&gt;'
  28. access_key_secret = '&lt;access_key_secret&gt;'
  29. client = client.AcsClient(access_key_id, access_key_secret, region)
  30. request = SearchPipelineRequest.SearchPipelineRequest()
  31. response = client.do_action_with_exception(request);
  32. json_response = json.loads(response)
  33. pipeline = json_response['PipelineList']['Pipeline'][0]
  34. request = UpdatePipelineRequest.UpdatePipelineRequest()
  35. request.set_PipelineId(pipeline['Id'])
  36. request.set_Name(pipeline['Name'])
  37. request.set_State('Paused' if pipeline['State'] == 'Active' else 'Active')
  38. response = client.do_action_with_exception(request);
  39. json_response = json.loads(response)
  40. pipeline = json_response['Pipeline']
  41. print 'pipeline id:' + pipeline['Id'] + ', name:' + pipeline['Name'] + ', state:' + pipeline['State']</code></pre></div>
  42. </section>
  43. </div>
  44. </article>
  45. </main>