Beispiel #1
0
        private async Task InitBigtableInstanceAndTable()
        {
            if (EmulatorChannel == null)
            {
                InstanceAdminClient = BigtableInstanceAdminClient.Create();
                TableAdminClient    = BigtableTableAdminClient.Create();
                TableClient         = BigtableClient.Create();

                try
                {
                    await InstanceAdminClient.GetInstanceAsync(InstanceName);
                }
                catch (RpcException e) when(e.Status.StatusCode == StatusCode.NotFound)
                {
                    Assert.True(false, $"The Bigtable instance for testing does not exist: {InstanceName}");
                }
            }
            else
            {
                TableAdminClient = BigtableTableAdminClient.Create(EmulatorChannel);
                TableClient      = BigtableClient.Create(EmulatorChannel);
            }

            TableName = new TableName(ProjectName.ProjectId, InstanceName.InstanceId, "default-table");
            await CreateTable(TableName);
        }
Beispiel #2
0
        private async Task InitBigtableInstanceAndTable()
        {
            if (EmulatorChannel == null)
            {
                InstanceAdminClient = BigtableInstanceAdminClient.Create();
                TableAdminClient    = BigtableTableAdminClient.Create();
                TableClient         = BigtableClient.Create();

                try
                {
                    await InstanceAdminClient.GetInstanceAsync(InstanceName);
                }
                catch (RpcException e) when(e.Status.StatusCode == StatusCode.NotFound)
                {
                    Assert.True(false, $"The Bigtable instance for testing does not exist: {InstanceName}");
                }
            }
            else
            {
                TableAdminClient = BigtableTableAdminClient.Create(EmulatorChannel);
                TableClient      = BigtableClient.Create(BigtableClient.ClientCreationSettings.FromEndpointTarget(EmulatorChannel.Target));
            }

            TableName = await CreateTable();
        }
Beispiel #3
0
        /// <summary>Snippet for CreateTableFromSnapshot</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void CreateTableFromSnapshotRequestObject()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
            // Initialize request argument(s)
            CreateTableFromSnapshotRequest request = new CreateTableFromSnapshotRequest
            {
                ParentAsInstanceName = InstanceName.FromProjectInstance("[PROJECT]", "[INSTANCE]"),
                TableId = "",
                SourceSnapshotAsSnapshotName = SnapshotName.FromProjectInstanceClusterSnapshot("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"),
            };
            // Make the request
            Operation <Table, CreateTableFromSnapshotMetadata> response = bigtableTableAdminClient.CreateTableFromSnapshot(request);

            // Poll until the returned long-running operation is complete
            Operation <Table, CreateTableFromSnapshotMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Table result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Table, CreateTableFromSnapshotMetadata> retrievedResponse = bigtableTableAdminClient.PollOnceCreateTableFromSnapshot(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Table retrievedResult = retrievedResponse.Result;
            }
        }
Beispiel #4
0
        /// <summary>Snippet for CreateTableFromSnapshot</summary>
        public void CreateTableFromSnapshot()
        {
            // Snippet: CreateTableFromSnapshot(InstanceName,string,string,CallSettings)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
            // Initialize request argument(s)
            InstanceName parent         = new InstanceName("[PROJECT]", "[INSTANCE]");
            string       tableId        = "";
            string       sourceSnapshot = "";
            // Make the request
            Operation <Table, CreateTableFromSnapshotMetadata> response =
                bigtableTableAdminClient.CreateTableFromSnapshot(parent, tableId, sourceSnapshot);

            // Poll until the returned long-running operation is complete
            Operation <Table, CreateTableFromSnapshotMetadata> completedResponse =
                response.PollUntilCompleted();
            // Retrieve the operation result
            Table result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Table, CreateTableFromSnapshotMetadata> retrievedResponse =
                bigtableTableAdminClient.PollOnceCreateTableFromSnapshot(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Table retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Beispiel #5
0
        private static object GetTable(string tableId)
        {
            // [START bigtable_create_bigtableTableAdminClient]
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();

            // [END bigtable_create_bigtableTableAdminClient]

            Console.WriteLine("Getting table");
            // [START bigtable_get_table]
            // Getting information about a table.
            // Initialize request argument(s).
            // Table to get.
            TableName       tableName = new TableName(projectId, instanceId, tableId);
            GetTableRequest request   = new GetTableRequest
            {
                TableName = tableName
            };

            try
            {
                // Make the request
                Table table = bigtableTableAdminClient.GetTable(request);
                // [END bigtable_get_table]
                // Print table information.
                PrintTableInfo(table);
                // [START bigtable_get_table]
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error getting table {ex.Message}");
            }
            // [END bigtable_get_table]
            return(0);
        }
        /// <summary>Snippet for CreateBackup</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void CreateBackup()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
            // Initialize request argument(s)
            string parent   = "projects/[PROJECT]/instances/[INSTANCE]/clusters/[CLUSTER]";
            string backupId = "";
            Backup backup   = new Backup();
            // Make the request
            Operation <Backup, CreateBackupMetadata> response = bigtableTableAdminClient.CreateBackup(parent, backupId, backup);

            // Poll until the returned long-running operation is complete
            Operation <Backup, CreateBackupMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Backup result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Backup, CreateBackupMetadata> retrievedResponse = bigtableTableAdminClient.PollOnceCreateBackup(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Backup retrievedResult = retrievedResponse.Result;
            }
        }
Beispiel #7
0
        /// <summary>Snippet for SnapshotTable</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void SnapshotTableResourceNames()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
            // Initialize request argument(s)
            TableName   name        = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]");
            ClusterName cluster     = ClusterName.FromProjectInstanceCluster("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
            string      snapshotId  = "";
            string      description = "";
            // Make the request
            Operation <Snapshot, SnapshotTableMetadata> response = bigtableTableAdminClient.SnapshotTable(name, cluster, snapshotId, description);

            // Poll until the returned long-running operation is complete
            Operation <Snapshot, SnapshotTableMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Snapshot result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Snapshot, SnapshotTableMetadata> retrievedResponse = bigtableTableAdminClient.PollOnceSnapshotTable(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Snapshot retrievedResult = retrievedResponse.Result;
            }
        }
        /// <summary>Snippet for CreateTableFromSnapshot</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void CreateTableFromSnapshot()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
            // Initialize request argument(s)
            string parent         = "projects/[PROJECT]/instances/[INSTANCE]";
            string tableId        = "";
            string sourceSnapshot = "projects/[PROJECT]/instances/[INSTANCE]/clusters/[CLUSTER]/snapshots/[SNAPSHOT]";
            // Make the request
            Operation <Table, CreateTableFromSnapshotMetadata> response = bigtableTableAdminClient.CreateTableFromSnapshot(parent, tableId, sourceSnapshot);

            // Poll until the returned long-running operation is complete
            Operation <Table, CreateTableFromSnapshotMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Table result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Table, CreateTableFromSnapshotMetadata> retrievedResponse = bigtableTableAdminClient.PollOnceCreateTableFromSnapshot(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Table retrievedResult = retrievedResponse.Result;
            }
        }
Beispiel #9
0
        private async Task InitBigtableInstanceAndTable()
        {
            if (EmulatorCallInvoker == null)
            {
                InstanceAdminClient = BigtableInstanceAdminClient.Create();
                TableAdminClient    = BigtableTableAdminClient.Create();
                TableClient         = BigtableClient.Create();

                try
                {
                    await InstanceAdminClient.GetInstanceAsync(InstanceName);
                }
                catch (RpcException e) when(e.Status.StatusCode == StatusCode.NotFound)
                {
                    Assert.True(false, $"The Bigtable instance for testing does not exist: {InstanceName}");
                }
            }
            else
            {
                TableAdminClient = new BigtableTableAdminClientBuilder {
                    CallInvoker = EmulatorCallInvoker
                }.Build();
                TableClient = new BigtableClientBuilder {
                    CallInvoker = EmulatorCallInvoker
                }.Build();
            }

            TableName = await CreateTable();
        }
Beispiel #10
0
        /// <summary>Snippet for CreateBackup</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void CreateBackupRequestObject()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
            // Initialize request argument(s)
            CreateBackupRequest request = new CreateBackupRequest
            {
                ParentAsClusterName = ClusterName.FromProjectInstanceCluster("[PROJECT]", "[INSTANCE]", "[CLUSTER]"),
                BackupId            = "",
                Backup = new Backup(),
            };
            // Make the request
            Operation <Backup, CreateBackupMetadata> response = bigtableTableAdminClient.CreateBackup(request);

            // Poll until the returned long-running operation is complete
            Operation <Backup, CreateBackupMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Backup result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Backup, CreateBackupMetadata> retrievedResponse = bigtableTableAdminClient.PollOnceCreateBackup(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Backup retrievedResult = retrievedResponse.Result;
            }
        }
        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);
        }
Beispiel #12
0
 internal HelloWorld(HelloWorldSettings settings)
 {
     _settings = settings;
     _bigtableTableAdminClient = BigtableTableAdminClient.Create();
     _bigtableClient           = BigtableClient.Create();
     _tableNameAdmin           = new Google.Cloud.Bigtable.Admin.V2.TableName(_settings.ProjectId, _settings.InstanceId, _settings.TableName);
     _tableNameClient          = new Google.Cloud.Bigtable.V2.TableName(_settings.ProjectId, _settings.InstanceId, _settings.TableName);
 }
Beispiel #13
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());
            table.ColumnFamilies.Add("cell_plan", 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));
            BigtableVersion timestamp_minus_hr = new BigtableVersion(new DateTime(2020, 1, 10, 13, 0, 0, DateTimeKind.Utc));

            MutateRowsRequest.Types.Entry[] entries =
            {
                Mutations.CreateEntry(new BigtableByteString("phone#4c410523#20190501"),
                                      Mutations.SetCell("cell_plan",                                                "data_plan_01gb",  "false",           timestamp),
                                      Mutations.SetCell("cell_plan",                                                "data_plan_01gb",  "true",            timestamp_minus_hr),
                                      Mutations.SetCell("cell_plan",                                                "data_plan_05gb",  "true",            timestamp),
                                      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("cell_plan",                                                "data_plan_05gb",  "true",            timestamp),
                                      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("cell_plan",                                                "data_plan_05gb",  "true",            timestamp),
                                      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("cell_plan",                                                "data_plan_10gb",  "true",            timestamp),
                                      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("cell_plan",                                                "data_plan_10gb",  "true",            timestamp),
                                      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);
        }
 /// <summary>Snippet for GetIamPolicy</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetIamPolicyResourceNames()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     IResourceName resource = new UnparsedResourceName("a/wildcard/resource");
     // Make the request
     Policy response = bigtableTableAdminClient.GetIamPolicy(resource);
 }
 /// <summary>Snippet for GetSnapshot</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetSnapshotResourceNames()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     SnapshotName name = SnapshotName.FromProjectInstanceClusterSnapshot("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
     // Make the request
     Snapshot response = bigtableTableAdminClient.GetSnapshot(name);
 }
Beispiel #16
0
 /// <summary>Snippet for GetBackup</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetBackupResourceNames()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     BackupName name = BackupName.FromProjectInstanceClusterBackup("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]");
     // Make the request
     Backup response = bigtableTableAdminClient.GetBackup(name);
 }
        /// <summary>
        /// Create Table in Google Cloud Bigtable
        /// </summary>
        /// <returns></returns>
        public bool CreateTable()
        {
            SetEnvironmentVariable();

            if (!CheckProperty(true))
            {
                throw new Exception("One Or More Properties Not Set");
            }

            if (IsTableExists())
            {
                throw new Exception("Table Already Exists");
            }

            bool Created = false;

            try
            {
                var callSetting = CreateRetryCallSettings();
                var bigtableTableAdminClient = BigtableTableAdminClient.Create(settings: callSetting);
                bigtableTableAdminClient.CreateTable(
                    new InstanceName(ProjectId, InstanceId),
                    TableName, new Table
                {
                    Granularity    = Table.Types.TimestampGranularity.Millis,
                    ColumnFamilies =
                    {
                        {
                            ColumnFamily, new ColumnFamily
                            {
                                GcRule = new GcRule
                                {
                                    MaxNumVersions = 1
                                }
                            }
                        }
                    }
                });
                Created = true;
            }
            catch (RpcException ex)
            {
                if (ex.Status.StatusCode == StatusCode.AlreadyExists)
                {
                    Created = true;
                }
                else
                {
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Created);
        }
 /// <summary>Snippet for GetSnapshot</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetSnapshot()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/instances/[INSTANCE]/clusters/[CLUSTER]/snapshots/[SNAPSHOT]";
     // Make the request
     Snapshot response = bigtableTableAdminClient.GetSnapshot(name);
 }
 /// <summary>Snippet for GetIamPolicy</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetIamPolicy()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     string resource = "a/wildcard/resource";
     // Make the request
     Policy response = bigtableTableAdminClient.GetIamPolicy(resource);
 }
 /// <summary>Snippet for GetTable</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetTableResourceNames()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     TableName name = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]");
     // Make the request
     Table response = bigtableTableAdminClient.GetTable(name);
 }
Beispiel #21
0
 /// <summary>Snippet for GetBackup</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetBackup()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/instances/[INSTANCE]/clusters/[CLUSTER]/backups/[BACKUP]";
     // Make the request
     Backup response = bigtableTableAdminClient.GetBackup(name);
 }
 /// <summary>Snippet for GenerateConsistencyToken</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GenerateConsistencyToken()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/instances/[INSTANCE]/tables/[TABLE]";
     // Make the request
     GenerateConsistencyTokenResponse response = bigtableTableAdminClient.GenerateConsistencyToken(name);
 }
 /// <summary>Snippet for UpdateBackup</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void UpdateBackup()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     Backup    backup     = new Backup();
     FieldMask updateMask = new FieldMask();
     // Make the request
     Backup response = bigtableTableAdminClient.UpdateBackup(backup, updateMask);
 }
 /// <summary>Snippet for CheckConsistency</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CheckConsistencyResourceNames()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     TableName name             = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]");
     string    consistencyToken = "";
     // Make the request
     CheckConsistencyResponse response = bigtableTableAdminClient.CheckConsistency(name, consistencyToken);
 }
Beispiel #25
0
        /// <summary>Snippet for DeleteTable</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void DeleteTable()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
            // Initialize request argument(s)
            string name = "projects/[PROJECT]/instances/[INSTANCE]/tables/[TABLE]";

            // Make the request
            bigtableTableAdminClient.DeleteTable(name);
        }
 /// <summary>Snippet for TestIamPermissions</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void TestIamPermissionsResourceNames()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     IResourceName        resource    = new UnparsedResourceName("a/wildcard/resource");
     IEnumerable <string> permissions = new string[] { "", };
     // Make the request
     TestIamPermissionsResponse response = bigtableTableAdminClient.TestIamPermissions(resource, permissions);
 }
 /// <summary>Snippet for CheckConsistency</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CheckConsistency()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     string name             = "projects/[PROJECT]/instances/[INSTANCE]/tables/[TABLE]";
     string consistencyToken = "";
     // Make the request
     CheckConsistencyResponse response = bigtableTableAdminClient.CheckConsistency(name, consistencyToken);
 }
Beispiel #28
0
        private static object CreateMaxVersionsFamily(string tableId)
        {
            // [START bigtable_create_bigtableTableAdminClient]
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();

            // [END bigtable_create_bigtableTableAdminClient]

            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);
        }
Beispiel #29
0
        private static object UpdateFamily(string tableId)
        {
            // [START bigtable_create_bigtableTableAdminClient]
            BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();

            // [END bigtable_create_bigtableTableAdminClient]

            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);
        }
 /// <summary>Snippet for CreateTable</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CreateTable()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     string parent  = "projects/[PROJECT]/instances/[INSTANCE]";
     string tableId = "";
     Table  table   = new Table();
     // Make the request
     Table response = bigtableTableAdminClient.CreateTable(parent, tableId, table);
 }