使用 Amazon QuickSight CLI 使用 QuickSight Q 主題 - Amazon QuickSight

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 Amazon QuickSight CLI 使用 QuickSight Q 主題

 適用於:企業版 
   目標受眾:Amazon QuickSight 開發者 

您可以使用本節了解如何使用 Amazon QuickSight 命令列界面 (CLI) 處理 QuickSight Q 主題。

先決條件

在開始之前,請確定您具有授與 CLI 使用者呼叫 QuickSight API 作業的存取權限的 AWS Identity and Access Management (IAM) 角色。下表顯示了必須將哪些許可新增至 IAM 政策才能使用特定 API 操作。若要使用所有 Q 主題 API 操作,請新增資料表中列出的所有許可。

API 操作 IAM 政策

CreateTopic

quicksight:CreateTopic

quicksight:PassDataSet

ListTopics

quicksight:ListTopics

DescribeTopic

quicksight:DescribeTopic

DescribeTopicPermissions

quicksight:DescribeTopicPermissions

DescribeTopicRefresh

quicksight:DescribeTopicRefresh

DeleteTopic

quicksight:DeleteTopic

UpdateTopic

quicksight:UpdateTopic

quicksight:PassDataSet

UpdateTopicPermissions

quicksight:UpdateTopicPermissions

CreateTopicRefreshSchedule

quicksight:CreateTopicRefreshSchedule

ListTopicRefreshSchedules

quicksight:ListTopicRefreshSchedules

DescribeTopicRefreshSchedule

quicksight:DescribeTopicRefreshSchedule

UpdateTopicRefreshSchedule

quicksight:UpdateTopicRefreshSchedule

DeleteTopicRefreshSchedule

quicksight:DeleteTopicRefreshSchedule

下面的範例顯示允許使用者使用 ListTopics 操作的 IAM 政策。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "quicksight:ListTopics" ], "Resource": "*" } ] }

使用 QuickSight CLI 使用 QuickSight Q 主題

以下是建立新 Q 主題的範例。

aws quicksight create-topic --aws-account-id AWSACCOUNTID --topic-id TOPICID --topic TOPIC

您也可以藉助以下命令使用 CLI 骨架檔案來建立新的 Q 主題。如需 CLI 骨架檔案的詳細資訊,請參閱 Amazon QuickSight 開發人員指南中的使用 CLI 骨架檔案

aws quicksight create-topic --cli-input-json file://createtopic.json

當您建立新的 Q 主題時,資料集重新整理組態不會複製到該主題。若要為新主題設定主題重新整理排程,您可以進行 create-topic-refresh-schedule API 呼叫。如需使用 CLI 設定主題重新整理排程的詳細資訊,請參閱 使用 QuickSight CLI 設定 Q 主題重新整理排程

建立第一個 Q 主題後,您可以更新、刪除、列出或請求 Q 主題的摘要。

下面是更新 Q 主題的範例。

aws quicksight update-topic --aws-account-id AWSACCOUNTID --topic-id TOPICID --topic TOPIC

您也可以藉助以下命令使用 CLI 骨架檔案來更新 Q 主題。如需 CLI 骨架檔案的詳細資訊,請參閱 Amazon QuickSight 開發人員指南中的使用 CLI 骨架檔案

aws quicksight update-topic --cli-input-json file://updatetopic.json

下列範例提供 QuickSight 帳戶中所有 Q 主題的清單。

aws quicksight list-topics --aws-account-id AWSACCOUNTID

下面是刪除 Q 主題的範例。

aws quicksight delete-topic --aws-account-id AWSACCOUNTID --topic-id TOPICID

下面是獲取有關 Q 主題設定的資訊的範例。

aws quicksight describe-topic --aws-account-id AWSACCOUNTID --topic-id TOPICID

下面的命令會更新 Q 主題的許可。

aws quicksight update-topic-permissions --aws-account-id AWSACCOUNTID --topic-id TOPICID --grant-permissions Principal=arn:aws:quicksight:us-east-1:AWSACCOUNTID:user/default/USERNAME,Actions=quicksight:DescribeTopic --revoke-permissions Principal=arn:aws:quicksight:us-east-1:AWSACCOUNTID:user/default/USERNAME,Actions=quicksight:DescribeTopic

使用此grant-permissions參數可將讀取權限和作者權限授與 QuickSight 帳戶使用者。若要授予帳戶使用者讀取許可,請輸入值:"quicksight:DescribeTopic"。若要向帳戶使用者授予許可,請輸入下列值:

  • "quicksight:DescribeTopic"

  • "quicksight:DescribeTopicRefresh"

  • "quicksight:ListTopicRefreshSchedules"

  • "quicksight:DescribeTopicRefreshSchedule"

  • "quicksight:DeleteTopic"

  • "quicksight:UpdateTopic"

  • "quicksight:CreateTopicRefreshSchedule"

  • "quicksight:DeleteTopicRefreshSchedule"

  • "quicksight:UpdateTopicRefreshSchedule"

  • "quicksight:DescribeTopicPermissions"

  • "quicksight:UpdateTopicPermissions"

RevokePermissions 參數會撤銷授予帳戶使用者的所有許可。

以下命令描述 Q 主題的所有許可。

aws quicksight describe-topic-permissions --aws-account-id AWSACCOUNTID --topic-id TOPICID

使用 QuickSight CLI 設定 Q 主題重新整理排程

以下命令會建立 Q 主題的重新整理排程。

aws quicksight create-topic-refresh-schedule --aws-account-id AWSACCOUNTID --topic-id TOPICID --dataset-arn DATASETARN --refresh-schedule REFRESHSCHEDULE

為 Q 主題建立重新整理排程後,您可以更新、刪除、列出或請求主題重新整理排程的摘要。

以下命令會更新 Q 主題的重新整理排程。

aws quicksight update-topic-refresh-schedule --aws-account-id AWSACCOUNTID --topic-id TOPICID --dataset-id DATASETID --refresh-schedule REFRESHSCHEDULE

以下範例會獲取為相應 Q 主題設定的所有重新整理排程的清單。

aws quicksight list-topic-refresh-schedules --aws-account-id AWSACCOUNTID --topic-id TOPICID

以下範例會刪除主題重新整理排程。

aws quicksight delete-topic-refresh-schedule --aws-account-id AWSACCOUNTID --topic-id TOPICID --dataset-id DATASETID

以下範例會獲取相應主題有關重新整理排程設定的資訊。

aws quicksight describe-topic-refresh-schedule --aws-account-id AWSACCOUNTID --topic-id TOPICID --dataset-id DATASETID

在內部和之間複製和遷移 QuickSight Q 主題 AWS 帳戶

您可以使用 QuickSight 命令列介面 (CLI) 將 QuickSight Q 主題從一個帳戶移轉到另一個帳戶。您可以使用 QuickSight CLI 重複使用相同的主題,而不是跨多個儀表板、命名空間或帳戶手動複製相同的主題。此功能可節省 QuickSight 撰寫者的時間,並為多個儀表板的儀表板讀者建立標準化的主題體驗。

若要使用 QuickSight CLI 移轉 Q 主題,請使用下列程序

將 Q 主題遷移到另一個帳戶
  1. 首先,找到要遷移的主題。您可以使用 list-topics API 命令檢視 QuickSight 帳戶中每個 Q 主題的清單。

    aws quicksight list-topics --aws-account-id AWSACCOUNTID
  2. 取得 Q 主題清單後,找到要遷移的主題並進行 describe-topic 呼叫,以接收主題組態的 JSON 結構。

    aws quicksight describe-topic --aws-account-id AWSACCOUNTID --topic-id TOPICID

    以下是 describe-topic API 回應的範例。

    { "Status": 200, "TopicId": "TopicExample", "Arn": "string", "Topic": [ { "Name": "{}", "DataSets": [ { "DataSetArn": "{}", "DataSetName": "{}", "DataSetDescription": "{}", "DataAggregation": "{}", "Filters": [], "Columns": [], "CalculatedFields": [], "NamedEntities": [] } ] } ], "RequestId": "requestId" }
  3. 使用 JSON 回應建立架構檔案,您可以將其輸入至其他 QuickSight 帳戶的新create-topic呼叫中。在使用骨架檔案進行 API 呼叫之前,請確保變更骨架檔案中的 AWS 帳戶 ID 和資料集 ID,以使其與您要在其中新增 Q 主題的 AWS 帳戶 ID 和資料集 ID 相符。如需 CLI 骨架檔案的詳細資訊,請參閱 Amazon QuickSight 開發人員指南中的使用 CLI 骨架檔案

    aws quicksight create-topic --aws-account-id AWSACCOUNTID \ --cli-input-json file://./create-topic-cli-input.json

create-topic呼叫 QuickSight API 後,新主題就會出現在您的帳戶中。若要確認新主題是否存在,請list-topics呼叫 QuickSight API。如果複製的來源主題包含已驗證的答案,則這些答案不會遷移到新主題。若要查看原始主題所有已驗證的答案的清單,請使用 describe-topic API 呼叫。