描述排程查詢 - Amazon Timestream

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

描述排程查詢

您可以使用下列程式碼片段來描述排程查詢。

Java
public void describeScheduledQueries(String scheduledQueryArn) { System.out.println("Describing Scheduled Query"); try { DescribeScheduledQueryResult describeScheduledQueryResult = queryClient.describeScheduledQuery(new DescribeScheduledQueryRequest().withScheduledQueryArn(scheduledQueryArn)); System.out.println(describeScheduledQueryResult); } catch (ResourceNotFoundException e) { System.out.println("Scheduled Query doesn't exist"); throw e; } catch (Exception e) { System.out.println("Describe Scheduled Query failed: " + e); throw e; } }
Java v2
public void describeScheduledQueries(String scheduledQueryArn) { System.out.println("Describing Scheduled Query"); try { DescribeScheduledQueryResponse describeScheduledQueryResult = queryClient.describeScheduledQuery(DescribeScheduledQueryRequest.builder() .scheduledQueryArn(scheduledQueryArn) .build()); System.out.println(describeScheduledQueryResult); } catch (ResourceNotFoundException e) { System.out.println("Scheduled Query doesn't exist"); throw e; } catch (Exception e) { System.out.println("Describe Scheduled Query failed: " + e); throw e; } }
Go
func (timestreamBuilder TimestreamBuilder) DescribeScheduledQuery(scheduledQueryArn string) error { describeScheduledQueryInput := &timestreamquery.DescribeScheduledQueryInput{ ScheduledQueryArn: aws.String(scheduledQueryArn), } describeScheduledQueryOutput, err := timestreamBuilder.QuerySvc.DescribeScheduledQuery(describeScheduledQueryInput) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case timestreamquery.ErrCodeResourceNotFoundException: fmt.Println(timestreamquery.ErrCodeResourceNotFoundException, aerr.Error()) default: fmt.Printf("Error: %s", err.Error()) } } else { fmt.Printf("Error: %s", aerr.Error()) } return err } else { fmt.Println("DescribeScheduledQuery is successful, below is the output:") fmt.Println(describeScheduledQueryOutput.ScheduledQuery) return nil } }
Python
def describe_scheduled_query(self, scheduled_query_arn): print("\nDescribing Scheduled Query") try: response = self.query_client.describe_scheduled_query(ScheduledQueryArn=scheduled_query_arn) if 'ScheduledQuery' in response: response = response['ScheduledQuery'] for key in response: print("{} :{}".format(key, response[key])) except self.query_client.exceptions.ResourceNotFoundException as err: print("Scheduled Query doesn't exist") raise err except Exception as err: print("Scheduled Query describe failed:", err) raise err
Node.js

下列程式碼片段使用 AWS SDK適用於 JavaScript V2 樣式的 。它以 Node.js 範例應用程式為基礎,適用於 上的 LiveAnalytics 應用程式 GitHub

async function describeScheduledQuery(scheduledQueryArn) { console.log("Describing Scheduled Query"); var params = { ScheduledQueryArn: scheduledQueryArn } try { const data = await queryClient.describeScheduledQuery(params).promise(); console.log(data.ScheduledQuery); } catch (err) { console.log("Describe Scheduled Query failed: ", err); throw err; } }
.NET
private async Task DescribeScheduledQuery(string scheduledQueryArn) { try { Console.WriteLine("Describing Scheduled Query"); DescribeScheduledQueryResponse response = await _amazonTimestreamQuery.DescribeScheduledQueryAsync( new DescribeScheduledQueryRequest() { ScheduledQueryArn = scheduledQueryArn }); Console.WriteLine($"{JsonConvert.SerializeObject(response.ScheduledQuery)}"); } catch (ResourceNotFoundException e) { Console.WriteLine($"Scheduled Query doesn't exist: {e}"); throw; } catch (Exception e) { Console.WriteLine($"Describe Scheduled Query failed: {e}"); throw; } }