Listar consulta programada - Amazon Timestream

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

Listar consulta programada

Puede usar los siguientes fragmentos de código para enumerar las consultas programadas.

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

En el siguiente fragmento se utiliza el estilo for V2. AWS SDK JavaScript Se basa en la aplicación de ejemplo de Node.js, ejemplo de Amazon Timestream LiveAnalytics para su aplicación en. 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; } }