本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
更新排程查詢
您可以使用下列程式碼片段來更新排程查詢。
- 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 := ×treamquery.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
-
下列程式碼片段使用 AWS SDK JavaScript V2 樣式的 。它以 Node.js 範例應用程式為基礎,適用於 上的 LiveAnalytics 應用程式 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; } }
執行排程查詢
刪除排程查詢