Répertorier une requête planifiée - Amazon Timestream

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

Répertorier une requête planifiée

Vous pouvez utiliser les extraits de code suivants pour répertorier vos requêtes planifiées.

Java
public void listScheduledQueries() { System.out.println("Listing Scheduled Query"); try { String nextToken = null; List<String> scheduledQueries = new ArrayList<>(); do { ListScheduledQueriesResult listScheduledQueriesResult = queryClient.listScheduledQueries(new ListScheduledQueriesRequest() .withNextToken(nextToken).withMaxResults(10)); List<ScheduledQuery> scheduledQueryList = listScheduledQueriesResult.getScheduledQueries(); printScheduledQuery(scheduledQueryList); nextToken = listScheduledQueriesResult.getNextToken(); } while (nextToken != null); } catch (Exception e) { System.out.println("List Scheduled Query failed: " + e); throw e; } } public void printScheduledQuery(List<ScheduledQuery> scheduledQueryList) { for (ScheduledQuery scheduledQuery: scheduledQueryList) { System.out.println(scheduledQuery.getArn()); } }
Java v2
public void listScheduledQueries() { System.out.println("Listing Scheduled Query"); try { String nextToken = null; do { ListScheduledQueriesResponse listScheduledQueriesResult = queryClient.listScheduledQueries(ListScheduledQueriesRequest.builder() .nextToken(nextToken).maxResults(10) .build()); List<ScheduledQuery> scheduledQueryList = listScheduledQueriesResult.scheduledQueries(); printScheduledQuery(scheduledQueryList); nextToken = listScheduledQueriesResult.nextToken(); } while (nextToken != null); } catch (Exception e) { System.out.println("List Scheduled Query failed: " + e); throw e; } } public void printScheduledQuery(List<ScheduledQuery> scheduledQueryList) { for (ScheduledQuery scheduledQuery: scheduledQueryList) { System.out.println(scheduledQuery.arn()); } }
Go
func (timestreamBuilder TimestreamBuilder) ListScheduledQueries() ([]*timestreamquery.ScheduledQuery, error) { var nextToken *string = nil var scheduledQueries []*timestreamquery.ScheduledQuery for ok := true; ok; ok = nextToken != nil { listScheduledQueriesInput := &timestreamquery.ListScheduledQueriesInput{ MaxResults: aws.Int64(15), } if nextToken != nil { listScheduledQueriesInput.NextToken = aws.String(*nextToken) } listScheduledQueriesOutput, err := timestreamBuilder.QuerySvc.ListScheduledQueries(listScheduledQueriesInput) if err != nil { fmt.Printf("Error: %s", err.Error()) return nil, err } scheduledQueries = append(scheduledQueries, listScheduledQueriesOutput.ScheduledQueries...) nextToken = listScheduledQueriesOutput.NextToken } return scheduledQueries, nil }
Python
def list_scheduled_queries(self): print("\nListing Scheduled Queries") try: response = self.query_client.list_scheduled_queries(MaxResults=10) self.print_scheduled_queries(response['ScheduledQueries']) next_token = response.get('NextToken', None) while next_token: response = self.query_client.list_scheduled_queries(NextToken=next_token, MaxResults=10) self.print_scheduled_queries(response['ScheduledQueries']) next_token = response.get('NextToken', None) except Exception as err: print("List scheduled queries failed:", err) raise err @staticmethod def print_scheduled_queries(scheduled_queries): for scheduled_query in scheduled_queries: print(scheduled_query['Arn'])
Node.js

L'extrait suivant utilise le style AWS SDK for JavaScript V2. Il est basé sur l'exemple d'application disponible sur Node.js, un exemple d'Amazon Timestream LiveAnalytics pour une application sur. GitHub

async function listScheduledQueries() { console.log("Listing Scheduled Query"); try { var nextToken = null; do { var params = { MaxResults: 10, NextToken: nextToken } var data = await queryClient.listScheduledQueries(params).promise(); var scheduledQueryList = data.ScheduledQueries; printScheduledQuery(scheduledQueryList); nextToken = data.NextToken; } while (nextToken != null); } catch (err) { console.log("List Scheduled Query failed: ", err); throw err; } } async function printScheduledQuery(scheduledQueryList) { scheduledQueryList.forEach(element => console.log(element.Arn)); }
.NET
private async Task ListScheduledQueries() { try { Console.WriteLine("Listing Scheduled Query"); string nextToken; do { ListScheduledQueriesResponse response = await _amazonTimestreamQuery.ListScheduledQueriesAsync(new ListScheduledQueriesRequest()); foreach (var scheduledQuery in response.ScheduledQueries) { Console.WriteLine($"{scheduledQuery.Arn}"); } nextToken = response.NextToken; } while (nextToken != null); } catch (Exception e) { Console.WriteLine($"List Scheduled Query failed: {e}"); throw; } }