スケジュールされたクエリを更新する - Amazon Timestream

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

スケジュールされたクエリを更新する

次のコードスニペットを使用して、スケジュールされたクエリを更新できます。

Java
public void updateScheduledQueries(String scheduledQueryArn) { System.out.println("Updating Scheduled Query"); try { queryClient.updateScheduledQuery(new UpdateScheduledQueryRequest() .withScheduledQueryArn(scheduledQueryArn) .withState(ScheduledQueryState.DISABLED)); System.out.println("Successfully update scheduled query state"); } catch (ResourceNotFoundException e) { System.out.println("Scheduled Query doesn't exist"); throw e; } catch (Exception e) { System.out.println("Execution Scheduled Query failed: " + e); throw e; } }
Java v2
public void updateScheduledQuery(String scheduledQueryArn, ScheduledQueryState state) { System.out.println("Updating Scheduled Query"); try { queryClient.updateScheduledQuery(UpdateScheduledQueryRequest.builder() .scheduledQueryArn(scheduledQueryArn) .state(state) .build()); System.out.println("Successfully update scheduled query state"); } catch (ResourceNotFoundException e) { System.out.println("Scheduled Query doesn't exist"); throw e; } catch (Exception e) { System.out.println("Execution Scheduled Query failed: " + e); throw e; } }
Go
func (timestreamBuilder TimestreamBuilder) UpdateScheduledQuery(scheduledQueryArn string) error { updateScheduledQueryInput := &timestreamquery.UpdateScheduledQueryInput{ ScheduledQueryArn: aws.String(scheduledQueryArn), State: aws.String(timestreamquery.ScheduledQueryStateDisabled), } _, err := timestreamBuilder.QuerySvc.UpdateScheduledQuery(updateScheduledQueryInput) 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", aerr.Error()) } } else { fmt.Printf("Error: %s", err.Error()) } return err } else { fmt.Println("UpdateScheduledQuery is successful") return nil } }
Python
def update_scheduled_query(self, scheduled_query_arn, state): print("\nUpdating Scheduled Query") try: self.query_client.update_scheduled_query(ScheduledQueryArn=scheduled_query_arn, State=state) print("Successfully update scheduled query state to", state) except self.query_client.exceptions.ResourceNotFoundException as err: print("Scheduled Query doesn't exist") raise err except Exception as err: print("Scheduled Query deletion failed:", err) raise err
Node.js

次のスニペットは JavaScript V2 スタイルに AWS SDKを使用します。これは、Node.js のサンプルアプリケーションに基づいており、 の LiveAnalytics アプリケーション用の Amazon Timestream サンプルです GitHub

async function updateScheduledQueries(scheduledQueryArn) { console.log("Updating Scheduled Query"); var params = { ScheduledQueryArn: scheduledQueryArn, State: "DISABLED" } try { await queryClient.updateScheduledQuery(params).promise(); console.log("Successfully update scheduled query state"); } catch (err) { console.log("Update Scheduled Query failed: ", err); throw err; } }
.NET
private async Task UpdateScheduledQuery(string scheduledQueryArn, ScheduledQueryState state) { try { Console.WriteLine("Updating Scheduled Query"); await _amazonTimestreamQuery.UpdateScheduledQueryAsync(new UpdateScheduledQueryRequest() { ScheduledQueryArn = scheduledQueryArn, State = state }); Console.WriteLine("Successfully update scheduled query state"); } catch (ResourceNotFoundException e) { Console.WriteLine($"Scheduled Query doesn't exist: {e}"); throw; } catch (Exception e) { Console.WriteLine($"Update Scheduled Query failed: {e}"); throw; } }