public static void ListTables(int maximumNumberOfTablesToReturn) //Made private for singleton { System.Diagnostics.Debug.WriteLine("\n*** listing tables ***"); string lastEvaluatedTableName = null; do { var request = new ListTablesRequest { Limit = maximumNumberOfTablesToReturn, ExclusiveStartTableName = lastEvaluatedTableName }; var response = _client.ListTablesAsync(request); //****** Adapted from https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LowLevelDotNetWorkingWithTables.html. var result = response.Result; foreach (string name in result.TableNames) { System.Diagnostics.Debug.WriteLine(name); } lastEvaluatedTableName = result.LastEvaluatedTableName; } while (lastEvaluatedTableName != null); //****** }
internal ListTablesResponse ListTables(ListTablesRequest request) { var marshaller = new ListTablesRequestMarshaller(); var unmarshaller = ListTablesResponseUnmarshaller.Instance; return(Invoke <ListTablesRequest, ListTablesResponse>(request, marshaller, unmarshaller)); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonDynamoDBConfig config = new AmazonDynamoDBConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonDynamoDBClient client = new AmazonDynamoDBClient(creds, config); ListTablesResponse resp = new ListTablesResponse(); do { ListTablesRequest req = new ListTablesRequest { ExclusiveStartTableName = resp.LastEvaluatedTableName , Limit = maxItems }; resp = client.ListTables(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.TableNames) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.LastEvaluatedTableName)); }
protected override void ProcessRecord() { base.ProcessRecord(); ListTablesRequest request; try { request = new ListTablesRequest { CompartmentId = CompartmentId, Name = Name, Limit = Limit, Page = Page, SortOrder = SortOrder, SortBy = SortBy, OpcRequestId = OpcRequestId, LifecycleState = LifecycleState }; IEnumerable <ListTablesResponse> responses = GetRequestDelegate().Invoke(request); foreach (var item in responses) { response = item; WriteOutput(response, response.TableCollection, true); } if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null) { WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources."); } FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Get a list of tables in a compartment. /// </summary> /// <param name="request"></param> /// <returns></returns> public ListTablesResponse ListTables(ListTablesRequest request) { var uriStr = GetEndPoint(NoSQLServices.Tables, this.Region); var optional = request.GetOptionalQuery(); if (!string.IsNullOrEmpty(optional)) { uriStr = $"{uriStr}?{optional}"; } var uri = new Uri(uriStr); var httpRequestHeaderParam = new HttpRequestHeaderParam() { OpcRequestId = request.OpcRequestId }; using (var webResponse = this.RestClient.Get(uri, httpRequestHeaderParam)) using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = reader.ReadToEnd(); return(new ListTablesResponse() { TableCollection = this.JsonSerializer.Deserialize <TableCollection>(response), OpcRequestId = webResponse.Headers.Get("opc-request-id"), OpcNextPage = webResponse.Headers.Get("opc-next-page") }); } }
public async Task CreateTable() { // Request to know what tables are in our container var request = new ListTablesRequest { Limit = 10 }; var response = await _amazonDynamoDb.ListTablesAsync(request); // We save the existing tables names var results = response.TableNames; // We check if our table of interest is in the existing tables // if not we proceed to create the table if (!results.Any(_ => _.Equals($"{_dynamoSettings.TablePrefix}{_dynamoSettings.AuthorsTable}", StringComparison.OrdinalIgnoreCase))) { // Preparation for a table request creation // We will keep the request simple so we will just work with the following properties var authorsTableRequest = new CreateTableRequest { TableName = $"{_dynamoSettings.TablePrefix}{_dynamoSettings.AuthorsTable}", AttributeDefinitions = new List <AttributeDefinition> { new() { AttributeName = "Id", AttributeType = ScalarAttributeType.S } },
private void ListMyTables() { this.displayMessage = ("\n*** listing tables ***"); string lastTableNameEvaluated = null; var request = new ListTablesRequest { Limit = 2, ExclusiveStartTableName = lastTableNameEvaluated }; client.ListTablesAsync(request, (AmazonServiceResult result) => { if (result.Exception != null) { this.displayMessage = result.Exception.Message; Debug.Log(result.Exception); return; } this.displayMessage = "ListTable response : \n"; var response = result.Response as ListTablesResponse; foreach (string name in response.TableNames) { displayMessage += name + "\n"; } // repeat request to fetch more results lastTableNameEvaluated = response.LastEvaluatedTableName; }, null); }
/// <summary> /// テーブル名のリストを取得します。 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <List <string> > GetTableNameListAsync(ListTablesRequest request = null) { var res = request == null ? await _client.ListTablesAsync() : await _client.ListTablesAsync(request); return(res.TableNames); }
public async Task ListTables() { Console.WriteLine("Listing Tables"); try { var listTablesRequest = new ListTablesRequest { MaxResults = 5, DatabaseName = Constants.DATABASE_NAME }; ListTablesResponse response = await writeClient.ListTablesAsync(listTablesRequest); PrintTables(response.Tables); string nextToken = response.NextToken; while (nextToken != null) { listTablesRequest.NextToken = nextToken; response = await writeClient.ListTablesAsync(listTablesRequest); PrintTables(response.Tables); nextToken = response.NextToken; } } catch (Exception e) { Console.WriteLine("List table failed:" + e.ToString()); } }
public static async Task <List <string> > GetTables(this AmazonDynamoDBClient client) { var tableNames = new List <string>(); string lastTableNameEvaluated = null; do { // needs to be in a loop because ListTablesAsync can return up to 100 records at a time var request = new ListTablesRequest { Limit = 100, ExclusiveStartTableName = lastTableNameEvaluated }; var response = await client.ListTablesAsync(request); foreach (string name in response.TableNames) { tableNames.Add(name); } lastTableNameEvaluated = response.LastEvaluatedTableName; } while (lastTableNameEvaluated != null); return(tableNames); }
protected override void ProcessRecord() { base.ProcessRecord(); ListTablesRequest request; try { request = new ListTablesRequest { CompartmentId = CompartmentId, Name = Name, Limit = Limit, Page = Page, SortOrder = SortOrder, SortBy = SortBy, OpcRequestId = OpcRequestId, LifecycleState = LifecycleState }; IEnumerable <ListTablesResponse> responses = GetRequestDelegate().Invoke(request); foreach (var item in responses) { response = item; WriteOutput(response, response.TableCollection, true); } FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
public static async Task <bool> ListMyTables(AmazonDynamoDBClient client) { Console.WriteLine("\n*** listing tables ***"); string lastTableNameEvaluated = null; do { var request = new ListTablesRequest { Limit = 2, ExclusiveStartTableName = lastTableNameEvaluated }; var response = await client.ListTablesAsync(request); foreach (string name in response.TableNames) { Console.WriteLine(name); } lastTableNameEvaluated = response.LastEvaluatedTableName; } while (lastTableNameEvaluated != null); return(true); }
private async Task <List <string> > GetTables() { if (_tables != null) { return(_tables); } _tables = new List <string>(); string lastTableNameEvaluated = null; do { var request = new ListTablesRequest { Limit = 100, ExclusiveStartTableName = lastTableNameEvaluated }; var response = await _client.ListTablesAsync(request); foreach (string name in response.TableNames) { _tables.Add(name); } lastTableNameEvaluated = response.LastEvaluatedTableName; } while (lastTableNameEvaluated != null); return(_tables); }
public async Task <List <string> > ListTables() { var request = new ListTablesRequest(); var response = await Client.ListTablesAsync(request); return(response.TableNames); }
/// <summary> /// <para>Returns an array of table names associated with the current account and endpoint. The output from <i>ListTables</i> is paginated, with /// each page returning a maximum of 100 table names.</para> /// </summary> /// /// <param name="listTablesRequest">Container for the necessary parameters to execute the ListTables service method on AmazonDynamoDBv2.</param> /// /// <returns>The response from the ListTables service method, as returned by AmazonDynamoDBv2.</returns> /// /// <exception cref="T:Amazon.DynamoDBv2.Model.InternalServerErrorException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public Task <ListTablesResponse> ListTablesAsync(ListTablesRequest listTablesRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListTablesRequestMarshaller(); var unmarshaller = ListTablesResponseUnmarshaller.GetInstance(); return(Invoke <IRequest, ListTablesRequest, ListTablesResponse>(listTablesRequest, marshaller, unmarshaller, signer, cancellationToken)); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonTimestreamWriteConfig config = new AmazonTimestreamWriteConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonTimestreamWriteClient client = new AmazonTimestreamWriteClient(creds, config); ListTablesResponse resp = new ListTablesResponse(); do { ListTablesRequest req = new ListTablesRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.ListTables(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Tables) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
private static object ListTables() { BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create(); Console.WriteLine("Listing tables"); // [START bigtable_list_tables] // Lists tables in intance. // Initialize request argument(s). ListTablesRequest request = new ListTablesRequest { ParentAsInstanceName = s_instanceName }; try { // Make the request. PagedEnumerable <ListTablesResponse, Table> response = bigtableTableAdminClient.ListTables(request); // [END bigtable_list_tables] // Iterate over all response items, lazily performing RPCs as required foreach (Table table in response) { // Print table information. PrintTableInfo(table); } // [START bigtable_list_tables] } catch (Exception ex) { Console.WriteLine($"Error listing tables {ex.Message}"); } // [END bigtable_list_tables] return(0); }
void ListTableListener() { resultText.text = "\n*** listing tables ***"; string lastTableNameEvaluated = null; var request = new ListTablesRequest { Limit = 2, ExclusiveStartTableName = lastTableNameEvaluated }; Client.ListTablesAsync(request, (result) => { if (result.Exception != null) { resultText.text += result.Exception.Message; return; } resultText.text += "ListTable response : \n"; var response = result.Response; foreach (string name in response.TableNames) { resultText.text += name + "\n"; } // repeat request to fetch more results lastTableNameEvaluated = response.LastEvaluatedTableName; }); }
/// <summary> /// Initiates the asynchronous execution of the ListTables operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListTables operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <ListTablesResponse> ListTablesAsync(ListTablesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListTablesRequestMarshaller(); var unmarshaller = ListTablesResponseUnmarshaller.Instance; return(InvokeAsync <ListTablesRequest, ListTablesResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// List the tables in a database. If neither <code>SchemaPattern</code> nor <code>TablePattern</code> /// are specified, then all tables in the database are returned. A token is returned to /// page through the table list. Depending on the authorization method, use one of the /// following combinations of request parameters: /// /// <ul> <li> /// <para> /// AWS Secrets Manager - specify the Amazon Resource Name (ARN) of the secret and the /// cluster identifier that matches the cluster in the secret. /// </para> /// </li> <li> /// <para> /// Temporary credentials - specify the cluster identifier, the database name, and the /// database user name. Permission to call the <code>redshift:GetClusterCredentials</code> /// operation is required to use this method. /// </para> /// </li> </ul> /// </summary> /// <param name="request">Container for the necessary parameters to execute the ListTables service method.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the ListTables service method, as returned by RedshiftDataAPIService.</returns> /// <exception cref="Amazon.RedshiftDataAPIService.Model.InternalServerException"> /// The Amazon Redshift Data API operation failed due to invalid input. /// </exception> /// <exception cref="Amazon.RedshiftDataAPIService.Model.ValidationException"> /// The Amazon Redshift Data API operation failed due to invalid input. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/redshift-data-2019-12-20/ListTables">REST API Reference for ListTables Operation</seealso> public virtual Task <ListTablesResponse> ListTablesAsync(ListTablesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = ListTablesRequestMarshaller.Instance; options.ResponseUnmarshaller = ListTablesResponseUnmarshaller.Instance; return(InvokeAsync <ListTablesResponse>(request, options, cancellationToken)); }
internal virtual ListTablesResponse ListTables(ListTablesRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = ListTablesRequestMarshaller.Instance; options.ResponseUnmarshaller = ListTablesResponseUnmarshaller.Instance; return(Invoke <ListTablesResponse>(request, options)); }
/// <summary> /// Initiates the asynchronous execution of the ListTables operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListTables operation on AmazonRedshiftDataAPIServiceClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListTables /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/redshift-data-2019-12-20/ListTables">REST API Reference for ListTables Operation</seealso> public virtual IAsyncResult BeginListTables(ListTablesRequest request, AsyncCallback callback, object state) { var options = new InvokeOptions(); options.RequestMarshaller = ListTablesRequestMarshaller.Instance; options.ResponseUnmarshaller = ListTablesResponseUnmarshaller.Instance; return(BeginInvoke(request, options, callback, state)); }
public async Task <ListTablesResponse> GetDynamoDBList(ListTablesRequest request) { using (var dynamoDBClient = new AmazonDynamoDBClient(awsCredentials, RegionEndpoint.GetBySystemName(Region))) { var response = await dynamoDBClient.ListTablesAsync(request); return(response); } }
public async Task DynamoDbTearDown() { //delete the table created above var request = new ListTablesRequest(); var listTablesResponse = DatabaseClient.DynamoDBClient.ListTablesAsync(request).Result; if (listTablesResponse.TableNames.Contains(tableName)) { await DatabaseClient.DynamoDBClient.DeleteTableAsync(tableName); } }
/// <summary> /// Returns an array of table names associated with the current account and endpoint as an asynchronous operation. /// </summary> /// <param name="setup">The <see cref="ListTablesOptions" /> which need to be configured.</param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <ListTablesResponse> ListAsync(Action <ListTablesOptions> setup = null) { var options = setup.ConfigureOptions(); var ltr = new ListTablesRequest() { ExclusiveStartTableName = options.ExclusiveStartTableName, Limit = options.Limit }; return(Client.ListTablesAsync(ltr, options.CancellationToken)); }
/// <summary> /// Creates the Recipes table, if it does not already exist. /// </summary> /// <returns>True if there's a good table to use, false otherwise.</returns> public static async Task <bool> EnsureTableExists(IAmazonDynamoDB client) { Console.WriteLine($"Dynamo URL is {client.Config.ServiceURL}"); Console.WriteLine($"Dynamo RegionName is {client.Config.RegionEndpointServiceName}"); var request = new ListTablesRequest { Limit = 10 }; var response = await client.ListTablesAsync(request); if (!response.TableNames.Contains("Recipe")) { var createRequest = new CreateTableRequest { TableName = "Recipe", AttributeDefinitions = new List <AttributeDefinition> { new AttributeDefinition { AttributeName = "UserId", AttributeType = "S" }, new AttributeDefinition { AttributeName = "RecipeId", AttributeType = "N" } }, KeySchema = new List <KeySchemaElement> { new KeySchemaElement { AttributeName = "UserId", KeyType = "HASH" }, new KeySchemaElement { AttributeName = "RecipeId", KeyType = "RANGE" } }, ProvisionedThroughput = new ProvisionedThroughput { ReadCapacityUnits = 5, WriteCapacityUnits = 5 } }; var created = await client.CreateTableAsync(createRequest); return(created.HttpStatusCode == System.Net.HttpStatusCode.OK); } return(true); // It already existed. }
public static async Task <List <string> > GetTablesList() { using (IAmazonDynamoDB client = GetDynamoDbClient()) { ListTablesRequest listTablesRequest = new ListTablesRequest(); listTablesRequest.Limit = 5; ListTablesResponse listTablesResponse = await client.ListTablesAsync(listTablesRequest); return(listTablesResponse.TableNames); } }
public async Task <bool> CheckHealthAsync() { var request = new ListTablesRequest { Limit = 10 }; var response = await _client.ListTablesAsync(request); var results = response.TableNames; var tableData = await _client.DescribeTableAsync("adverts"); return(string.Compare(tableData.Table.TableStatus, "active", true) == 0); }
public async Task InitTables() { var request = new ListTablesRequest { Limit = 10 }; var response = await amazonDynamoDb.ListTablesAsync(request); var results = response.TableNames; await CreateTableIfNotExists(results, UserTableName); await CreateTableIfNotExists(results, DocumentTableName); }
/// <summary> /// Retrives a list of tables from the server. /// </summary> /// <returns></returns> public async Task <IEnumerable <BigTable> > ListTablesAsync(Encoding encoding = null) { encoding = encoding ?? BigModel.DefaultEncoding; var request = new ListTablesRequest { Name = ClusterId }; var response = await _client.ListTablesAsync(request); await Task.Yield(); var results = response.Tables.Select(table => new BigTable(table, encoding, ClusterId)); return(results.ToArray()); }