Exemplo n.º 1
0
 /// <summary>Snippet for CreateTable</summary>
 public void CreateTable()
 {
     // Snippet: CreateTable(InstanceName,string,Table,CallSettings)
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     InstanceName parent  = new InstanceName("[PROJECT]", "[INSTANCE]");
     string       tableId = "";
     Table        table   = new Table();
     // Make the request
     Table response = bigtableTableAdminClient.CreateTable(parent, tableId, table);
     // End snippet
 }
        private static object CreateMaxVersionsFamily(string tableId)
        {
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();

            Console.WriteLine("Creating column family cf2 with max versions GC rule...");
            // [START bigtable_create_family_gc_max_versions]
            // Create a column family with GC policy : most recent N versions
            // where 1 = most recent version
            // Initialize request argument(s).
            // Define the GC policy to retain only the most recent 2 versions
            GcRule maxVersionsRule = new GcRule {
                MaxNumVersions = 2
            };

            // Column family to create
            ColumnFamily columnFamily = new ColumnFamily {
                GcRule = maxVersionsRule
            };

            TableName tableName = new TableName(projectId, instanceId, tableId);

            // Modification to create column family
            ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification
            {
                Create = columnFamily,
                Id     = "cf2"
            };

            ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest
            {
                TableName     = tableName,
                Modifications = { modification }
            };

            try
            {
                // Make the request
                Table response = bigtableTableAdminClient.ModifyColumnFamilies(request);
                Console.WriteLine("Created column family");
                // [END bigtable_create_family_gc_max_versions]
                // Print table information.
                GetTable(tableId);
                // [START bigtable_create_family_gc_max_versions]
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error creating column family {ex.Message}");
            }
            // [END bigtable_create_family_gc_max_versions]
            return(0);
        }
        private static object UpdateFamily(string tableId)
        {
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();

            Console.WriteLine("Updating column family cf1 GC rule...");
            // [START bigtable_update_gc_rule]
            // Update the column family metadata to update the GC rule.
            // Initialize request argument(s).
            // Updated column family GC rule.
            GcRule maxVersionsRule = new GcRule {
                MaxNumVersions = 1
            };

            // Column family to create
            ColumnFamily columnFamily = new ColumnFamily {
                GcRule = maxVersionsRule
            };

            TableName tableName = new TableName(projectId, instanceId, tableId);

            // Modification to update column family
            ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification
            {
                Update = columnFamily,
                Id     = "cf1"
            };

            ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest
            {
                TableName     = tableName,
                Modifications = { modification }
            };

            try
            {
                // Make the request
                Table response = bigtableTableAdminClient.ModifyColumnFamilies(request);
                Console.WriteLine("Updated column family");
                // [END bigtable_update_gc_rule]
                // Print table information.
                GetTable(tableId);
                // [START bigtable_update_gc_rule]
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error updating column family {ex.Message}");
            }

            // [END bigtable_update_gc_rule]
            return(0);
        }
Exemplo n.º 4
0
        /// <summary>Snippet for TestIamPermissionsAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task TestIamPermissionsRequestObjectAsync()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                ResourceAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
                Permissions            = { "", },
            };
            // Make the request
            TestIamPermissionsResponse response = await bigtableTableAdminClient.TestIamPermissionsAsync(request);
        }
        /// <summary>Snippet for DropRowRangeAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task DropRowRangeRequestObjectAsync()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            DropRowRangeRequest request = new DropRowRangeRequest
            {
                TableName    = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]"),
                RowKeyPrefix = ByteString.Empty,
            };
            // Make the request
            await bigtableTableAdminClient.DropRowRangeAsync(request);
        }
Exemplo n.º 6
0
        /// <summary>Snippet for GetTableAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetTableRequestObjectAsync()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            GetTableRequest request = new GetTableRequest
            {
                TableName = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]"),
                View      = Table.Types.View.Unspecified,
            };
            // Make the request
            Table response = await bigtableTableAdminClient.GetTableAsync(request);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Delete Table from Google Cloud Bigtable
 /// </summary>
 /// <returns></returns>
 public bool DeleteTable()
 {
     try
     {
         BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
         bigtableTableAdminClient.DeleteTable(
             new TableName(ProjectId, InstanceId, TableName));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(true);
 }
        /// <summary>Snippet for ModifyColumnFamiliesAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ModifyColumnFamiliesAsync()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            string name = "projects/[PROJECT]/instances/[INSTANCE]/tables/[TABLE]";
            IEnumerable <ModifyColumnFamiliesRequest.Types.Modification> modifications = new ModifyColumnFamiliesRequest.Types.Modification[]
            {
                new ModifyColumnFamiliesRequest.Types.Modification(),
            };
            // Make the request
            Table response = await bigtableTableAdminClient.ModifyColumnFamiliesAsync(name, modifications);
        }
        /// <summary>Snippet for UpdateBackupAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task UpdateBackupRequestObjectAsync()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            UpdateBackupRequest request = new UpdateBackupRequest
            {
                Backup     = new Backup(),
                UpdateMask = new FieldMask(),
            };
            // Make the request
            Backup response = await bigtableTableAdminClient.UpdateBackupAsync(request);
        }
        /// <summary>Snippet for CheckConsistencyAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task CheckConsistencyRequestObjectAsync()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            CheckConsistencyRequest request = new CheckConsistencyRequest
            {
                TableName        = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]"),
                ConsistencyToken = "",
            };
            // Make the request
            CheckConsistencyResponse response = await bigtableTableAdminClient.CheckConsistencyAsync(request);
        }
Exemplo n.º 11
0
 /// <summary>Snippet for GetSnapshot</summary>
 public void GetSnapshot_RequestObject()
 {
     // Snippet: GetSnapshot(GetSnapshotRequest,CallSettings)
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     GetSnapshotRequest request = new GetSnapshotRequest
     {
         SnapshotName = new SnapshotName("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"),
     };
     // Make the request
     Snapshot response = bigtableTableAdminClient.GetSnapshot(request);
     // End snippet
 }
Exemplo n.º 12
0
        /// <summary>Snippet for GetSnapshotAsync</summary>
        public async Task GetSnapshotAsync()
        {
            // Snippet: GetSnapshotAsync(SnapshotName,CallSettings)
            // Additional: GetSnapshotAsync(SnapshotName,CancellationToken)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            SnapshotName name = new SnapshotName("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
            // Make the request
            Snapshot response = await bigtableTableAdminClient.GetSnapshotAsync(name);

            // End snippet
        }
Exemplo n.º 13
0
        /// <summary>Snippet for ModifyColumnFamiliesAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ModifyColumnFamiliesResourceNamesAsync()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            TableName name = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]");
            IEnumerable <ModifyColumnFamiliesRequest.Types.Modification> modifications = new ModifyColumnFamiliesRequest.Types.Modification[]
            {
                new ModifyColumnFamiliesRequest.Types.Modification(),
            };
            // Make the request
            Table response = await bigtableTableAdminClient.ModifyColumnFamiliesAsync(name, modifications);
        }
        /// <summary>Snippet for GetIamPolicyAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetIamPolicyRequestObjectAsync()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            GetIamPolicyRequest request = new GetIamPolicyRequest
            {
                ResourceAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
                Options = new GetPolicyOptions(),
            };
            // Make the request
            Policy response = await bigtableTableAdminClient.GetIamPolicyAsync(request);
        }
 /// <summary>Snippet for GetIamPolicy</summary>
 public void GetIamPolicy_RequestObject()
 {
     // Snippet: GetIamPolicy(GetIamPolicyRequest,CallSettings)
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     GetIamPolicyRequest request = new GetIamPolicyRequest
     {
         Resource = new Google.Cloud.Bigtable.Common.V2.TableName("[PROJECT]", "[INSTANCE]", "[TABLE]").ToString(),
     };
     // Make the request
     Policy response = bigtableTableAdminClient.GetIamPolicy(request);
     // End snippet
 }
        /// <summary>Snippet for GetIamPolicyAsync</summary>
        public async Task GetIamPolicyAsync()
        {
            // Snippet: GetIamPolicyAsync(string,CallSettings)
            // Additional: GetIamPolicyAsync(string,CancellationToken)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            string formattedResource = new Google.Cloud.Bigtable.Common.V2.TableName("[PROJECT]", "[INSTANCE]", "[TABLE]").ToString();
            // Make the request
            Policy response = await bigtableTableAdminClient.GetIamPolicyAsync(formattedResource);

            // End snippet
        }
Exemplo n.º 17
0
 /// <summary>Snippet for GenerateConsistencyToken</summary>
 public void GenerateConsistencyToken_RequestObject()
 {
     // Snippet: GenerateConsistencyToken(GenerateConsistencyTokenRequest,CallSettings)
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     GenerateConsistencyTokenRequest request = new GenerateConsistencyTokenRequest
     {
         TableName = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
     };
     // Make the request
     GenerateConsistencyTokenResponse response = bigtableTableAdminClient.GenerateConsistencyToken(request);
     // End snippet
 }
Exemplo n.º 18
0
        /// <summary>Snippet for GenerateConsistencyTokenAsync</summary>
        public async Task GenerateConsistencyTokenAsync()
        {
            // Snippet: GenerateConsistencyTokenAsync(TableName,CallSettings)
            // Additional: GenerateConsistencyTokenAsync(TableName,CancellationToken)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            TableName name = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]");
            // Make the request
            GenerateConsistencyTokenResponse response = await bigtableTableAdminClient.GenerateConsistencyTokenAsync(name);

            // End snippet
        }
Exemplo n.º 19
0
        public BigtableClientFixture()
        {
            BigtableClient bigtableClient = BigtableClient.Create();

            _bigtableTableAdminClient = BigtableTableAdminClient.Create();
            Table table = new Table
            {
                Granularity = Table.Types.TimestampGranularity.Millis
            };

            table.ColumnFamilies.Add("stats_summary", new ColumnFamily());
            CreateTableRequest createTableRequest = new CreateTableRequest
            {
                ParentAsInstanceName = new InstanceName(projectId, instanceId),
                Table   = table,
                TableId = tableId,
            };

            _bigtableTableAdminClient.CreateTable(createTableRequest);

            TableName       tableName = new TableName(projectId, instanceId, tableId);
            BigtableVersion timestamp = new BigtableVersion(new DateTime(2020, 1, 10, 14, 0, 0, DateTimeKind.Utc));

            MutateRowsRequest.Types.Entry[] entries =
            {
                Mutations.CreateEntry(new BigtableByteString("phone#4c410523#20190501"),
                                      Mutations.SetCell("stats_summary",                                            "connected_cell",  "1",               timestamp),
                                      Mutations.SetCell("stats_summary",                                            "connected_wifi",  "1",               timestamp),
                                      Mutations.SetCell("stats_summary",                                            "os_build",        "PQ2A.190405.003", timestamp)),
                Mutations.CreateEntry(new BigtableByteString("phone#4c410523#20190502"),
                                      Mutations.SetCell("stats_summary",                                            "connected_cell",  "1",               timestamp),
                                      Mutations.SetCell("stats_summary",                                            "connected_wifi",  "1",               timestamp),
                                      Mutations.SetCell("stats_summary",                                            "os_build",        "PQ2A.190405.004", timestamp)),
                Mutations.CreateEntry(new BigtableByteString("phone#4c410523#20190505"),
                                      Mutations.SetCell("stats_summary",                                            "connected_cell",  "0",               timestamp),
                                      Mutations.SetCell("stats_summary",                                            "connected_wifi",  "1",               timestamp),
                                      Mutations.SetCell("stats_summary",                                            "os_build",        "PQ2A.190406.000", timestamp)),
                Mutations.CreateEntry(new BigtableByteString("phone#5c10102#20190501"),
                                      Mutations.SetCell("stats_summary",                                            "connected_cell",  "1",               timestamp),
                                      Mutations.SetCell("stats_summary",                                            "connected_wifi",  "1",               timestamp),
                                      Mutations.SetCell("stats_summary",                                            "os_build",        "PQ2A.190401.002", timestamp)),
                Mutations.CreateEntry(new BigtableByteString("phone#5c10102#20190502"),
                                      Mutations.SetCell("stats_summary",                                            "connected_cell",  "1",               timestamp),
                                      Mutations.SetCell("stats_summary",                                            "connected_wifi",  "0",               timestamp),
                                      Mutations.SetCell("stats_summary",                                            "os_build",        "PQ2A.190406.000", timestamp))
            };

            bigtableClient.MutateRows(tableName, entries);
        }
        private static object CreateMaxAgeFamily(string tableId)
        {
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();

            Console.WriteLine("Creating column family cf1 with max age GC rule...");
            // [START bigtable_create_family_gc_max_age]
            // Create a column family with GC policy : maximum age
            // where age = current time minus cell timestamp
            // Initialize request argument(s).
            // Define the GC rule to retain data with max age of 5 days
            GcRule MaxAgeRule = new GcRule {
                MaxAge = Duration.FromTimeSpan(TimeSpan.FromDays(5.0))
            };

            // Column family to create
            ColumnFamily columnFamily = new ColumnFamily {
                GcRule = MaxAgeRule
            };

            TableName tableName = new TableName(projectId, instanceId, tableId);

            // Modification to create column family
            ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification
            {
                Create = columnFamily,
                Id     = "cf1"
            };

            ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest
            {
                TableName     = tableName,
                Modifications = { modification }
            };

            try
            {
                // Make the request
                Table response = bigtableTableAdminClient.ModifyColumnFamilies(request);
                Console.WriteLine("Created column family");
                // Print table information.
                GetTable(tableId);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error creating column family {ex.Message}");
            }
            // [END bigtable_create_family_gc_max_age]
            return(0);
        }
        /// <summary>Snippet for TestIamPermissionsAsync</summary>
        public async Task TestIamPermissionsAsync()
        {
            // Snippet: TestIamPermissionsAsync(string,IEnumerable<string>,CallSettings)
            // Additional: TestIamPermissionsAsync(string,IEnumerable<string>,CancellationToken)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            string formattedResource         = new Google.Cloud.Bigtable.Common.V2.TableName("[PROJECT]", "[INSTANCE]", "[TABLE]").ToString();
            IEnumerable <string> permissions = new List <string>();
            // Make the request
            TestIamPermissionsResponse response = await bigtableTableAdminClient.TestIamPermissionsAsync(formattedResource, permissions);

            // End snippet
        }
Exemplo n.º 22
0
        /// <summary>Snippet for ModifyColumnFamiliesAsync</summary>
        public async Task ModifyColumnFamiliesAsync()
        {
            // Snippet: ModifyColumnFamiliesAsync(TableName,IEnumerable<ModifyColumnFamiliesRequest.Types.Modification>,CallSettings)
            // Additional: ModifyColumnFamiliesAsync(TableName,IEnumerable<ModifyColumnFamiliesRequest.Types.Modification>,CancellationToken)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            TableName name = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]");
            IEnumerable <ModifyColumnFamiliesRequest.Types.Modification> modifications = new List <ModifyColumnFamiliesRequest.Types.Modification>();
            // Make the request
            Table response = await bigtableTableAdminClient.ModifyColumnFamiliesAsync(name, modifications);

            // End snippet
        }
 /// <summary>Snippet for TestIamPermissions</summary>
 public void TestIamPermissions_RequestObject()
 {
     // Snippet: TestIamPermissions(TestIamPermissionsRequest,CallSettings)
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     TestIamPermissionsRequest request = new TestIamPermissionsRequest
     {
         Resource    = new Google.Cloud.Bigtable.Common.V2.TableName("[PROJECT]", "[INSTANCE]", "[TABLE]").ToString(),
         Permissions = { },
     };
     // Make the request
     TestIamPermissionsResponse response = bigtableTableAdminClient.TestIamPermissions(request);
     // End snippet
 }
Exemplo n.º 24
0
 /// <summary>Snippet for ModifyColumnFamilies</summary>
 public void ModifyColumnFamilies_RequestObject()
 {
     // Snippet: ModifyColumnFamilies(ModifyColumnFamiliesRequest,CallSettings)
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest
     {
         TableName     = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
         Modifications = { },
     };
     // Make the request
     Table response = bigtableTableAdminClient.ModifyColumnFamilies(request);
     // End snippet
 }
Exemplo n.º 25
0
 /// <summary>Snippet for CheckConsistency</summary>
 public void CheckConsistency_RequestObject()
 {
     // Snippet: CheckConsistency(CheckConsistencyRequest,CallSettings)
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     CheckConsistencyRequest request = new CheckConsistencyRequest
     {
         TableName        = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
         ConsistencyToken = "",
     };
     // Make the request
     CheckConsistencyResponse response = bigtableTableAdminClient.CheckConsistency(request);
     // End snippet
 }
Exemplo n.º 26
0
        /// <summary>Snippet for CheckConsistencyAsync</summary>
        public async Task CheckConsistencyAsync()
        {
            // Snippet: CheckConsistencyAsync(TableName,string,CallSettings)
            // Additional: CheckConsistencyAsync(TableName,string,CancellationToken)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            TableName name             = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]");
            string    consistencyToken = "";
            // Make the request
            CheckConsistencyResponse response = await bigtableTableAdminClient.CheckConsistencyAsync(name, consistencyToken);

            // End snippet
        }
Exemplo n.º 27
0
        /// <summary>Snippet for DropRowRange</summary>
        public void DropRowRange_RequestObject()
        {
            // Snippet: DropRowRange(DropRowRangeRequest,CallSettings)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
            // Initialize request argument(s)
            DropRowRangeRequest request = new DropRowRangeRequest
            {
                TableName = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
            };

            // Make the request
            bigtableTableAdminClient.DropRowRange(request);
            // End snippet
        }
        /// <summary>Snippet for DropRowRangeAsync</summary>
        public async Task DropRowRangeAsync()
        {
            // Snippet: DropRowRangeAsync(string,ByteString,CallSettings)
            // Additional: DropRowRangeAsync(string,ByteString,CancellationToken)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            string     formattedName = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]").ToString();
            ByteString rowKeyPrefix  = ByteString.CopyFromUtf8("");
            // Make the request
            await bigtableTableAdminClient.DropRowRangeAsync(formattedName, rowKeyPrefix);

            // End snippet
        }
Exemplo n.º 29
0
        private static object DeleteFamily(string tableId)
        {
            // [START bigtable_create_bigtableTableAdminClient]
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();

            // [END bigtable_create_bigtableTableAdminClient]

            Console.WriteLine("Deleting column family cf2 GC rule...");
            // [START bigtable_delete_family]
            // Delete a column family.
            // Initialize request argument(s).
            GcRule maxVersionsRule = new GcRule {
                MaxNumVersions = 1
            };

            TableName tableName = new TableName(projectId, instanceId, tableId);

            // Modification to update column family
            ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification
            {
                Drop = true,
                Id   = "cf2"
            };

            ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest
            {
                TableName     = tableName,
                Modifications = { modification }
            };

            try
            {
                // Make the request
                Table response = bigtableTableAdminClient.ModifyColumnFamilies(request);
                Console.WriteLine("Deleted column family");
                // [END bigtable_delete_family]
                // Print table information.
                GetTable(tableId);
                // [START bigtable_delete_family]
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error deleting column family {ex.Message}");
            }

            // [END bigtable_delete_family]
            return(0);
        }
Exemplo n.º 30
0
        private static object CreateTable(string tableId)
        {
            // [START bigtable_create_bigtableTableAdminClient]
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();

            // [END bigtable_create_bigtableTableAdminClient]

            Console.WriteLine("Creating table");
            // [START bigtable_create_table]
            // Creates table if doesn't exist.
            // Initialize request argument(s).
            // Table to create
            Table table = new Table
            {
                Granularity = Table.Types.TimestampGranularity.Millis
            };

            CreateTableRequest request = new CreateTableRequest
            {
                ParentAsInstanceName = s_instanceName,
                Table   = table,
                TableId = tableId
            };

            try
            {
                if (!TableExist(bigtableTableAdminClient, tableId))
                {
                    // Make the request.
                    Table response = bigtableTableAdminClient.CreateTable(request);
                    // [END bigtable_create_table]
                    // Print table information.
                    GetTable(tableId);
                    // [START bigtable_create_table]
                }
                else
                {
                    Console.WriteLine("Table exists");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error creating table {ex.Message}");
            }
            // [END bigtable_create_table]

            return(0);
        }