Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Perbarui kueri terjadwal
Anda dapat menggunakan cuplikan kode berikut untuk memperbarui kueri terjadwal.
- 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
-
Cuplikan berikut menggunakan gaya AWS SDK for JavaScript V2. Hal ini didasarkan pada aplikasi sampel Node.js Amazon Timestream untuk LiveAnalytics aplikasi
pada. 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; } }
Jalankan kueri terjadwal
Hapus kueri terjadwal