private void DeleteBucket(StorageClient client, string bucket, string userProject) { client.DeleteBucket(bucket, new DeleteBucketOptions { UserProject = userProject, DeleteObjects = true }); SleepAfterBucketCreateDelete(); }
public void Dispose() { int retryDelayMs = 0; for (int errorCount = 0; errorCount < 4; ++errorCount) { Thread.Sleep(retryDelayMs); retryDelayMs = (retryDelayMs + 1000) * 2; try { _storage.DeleteBucket(BucketName, new DeleteBucketOptions() { DeleteObjects = true }); } catch (Google.GoogleApiException e) when(e.Error.Code == 404) { return; // Bucket does not exist. Ok. } catch (Google.GoogleApiException) { continue; // Try again. } } }
public void ExportCsv() { // TODO: Make this simpler in the wrapper var projectId = _fixture.ProjectId; var datasetId = _fixture.GameDatasetId; var historyTableId = _fixture.HistoryTableId; string bucket = "bigquerysnippets-" + Guid.NewGuid().ToString().ToLowerInvariant(); string objectName = "table.csv"; if (!WaitForStreamingBufferToEmpty(historyTableId)) { Console.WriteLine("Streaming buffer not empty after 30 seconds; not performing export"); return; } // Sample: ExportCsv BigqueryClient client = BigqueryClient.Create(projectId); // Create a storage bucket; in normal use it's likely that one would exist already. StorageClient storageClient = StorageClient.Create(); storageClient.CreateBucket(projectId, bucket); string destinationUri = $"gs://{bucket}/{objectName}"; Job job = client.Service.Jobs.Insert(new Job { Configuration = new JobConfiguration { Extract = new JobConfigurationExtract { DestinationFormat = "CSV", DestinationUris = new[] { destinationUri }, SourceTable = client.GetTableReference(datasetId, historyTableId) } } }, projectId).Execute(); // Wait until the export has finished. var result = client.PollJob(job.JobReference); // If there are any errors, display them *then* fail. if (result.Status.ErrorResult != null) { foreach (var error in result.Status.Errors) { Console.WriteLine(error.Message); } } Assert.Null(result.Status.ErrorResult); MemoryStream stream = new MemoryStream(); storageClient.DownloadObject(bucket, objectName, stream); Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray())); // End sample storageClient.DeleteObject(bucket, objectName); storageClient.DeleteBucket(bucket); }
private static void DeleteBucket(StorageClient client, string bucket) { client.DeleteBucket(bucket, new DeleteBucketOptions { DeleteObjects = true }); // Avoid running into quota issues Thread.Sleep(2000); Console.WriteLine($"Deleted {bucket}"); }
public void Dispose() { _client.DeleteBucket(BucketName, new DeleteBucketOptions { DeleteObjects = true }); _client.Dispose(); DeleteGlossary.DeleteGlossarySample(ProjectId, GlossaryId); }
public void Dispose() { var robot = new RetryRobot() { MaxTryCount = 10, ShouldRetry = (e) => true, }; robot.Eventually(() => { _storage.DeleteBucket(BucketName); }); }
private void DeleteBucket(StorageClient client, string bucket, string userProject) { try { client.DeleteBucket(bucket, new DeleteBucketOptions { UserProject = userProject, DeleteObjects = true }); } catch (GoogleApiException) { // Some tests fail to delete buckets due to object retention locks etc. // They can be cleaned up later. } SleepAfterBucketCreateDelete(); }
public void Dispose() { int retryDelayMs = 0; for (int errorCount = 0; errorCount < 4; ++errorCount) { Thread.Sleep(retryDelayMs); retryDelayMs = (retryDelayMs + 1000) * 2; List <Google.Apis.Storage.v1.Data.Object> objectsInBucket = new List <Google.Apis.Storage.v1.Data.Object>(); try { objectsInBucket = _storage.ListObjects(BucketName).ToList(); } catch (Google.GoogleApiException e) when(e.Error.Code == 404) { // Bucket does not exist or is empty. } // Try to delete each object in the bucket. foreach (var obj in objectsInBucket) { try { _storage.DeleteObject(obj); } catch (Google.GoogleApiException) { continue; } } try { _storage.DeleteBucket(BucketName); } catch (Google.GoogleApiException e) when(e.Error.Code == 404) { return; // Bucket does not exist. Ok. } catch (Google.GoogleApiException) { continue; } } }
private static void DeleteBucket(StorageClient client, string bucket) { var objects = client.ListObjects(bucket, options: new ListObjectsOptions { Versions = true }); foreach (var obj in objects) { client.DeleteObject(bucket, obj.Name, new DeleteObjectOptions { Generation = obj.Generation }); Console.WriteLine($"Deleted {bucket} / {obj.Name} / v{obj.Generation}"); } client.DeleteBucket(bucket); Console.WriteLine($"Deleted {bucket}"); }
private void DeleteBucket(StorageClient client, string bucket, string userProject) { // TODO: We shouldn't need the project ID here. var objects = client.ListObjects(bucket, null, new ListObjectsOptions { Versions = true, UserProject = userProject }).ToList(); foreach (var obj in objects) { client.DeleteObject(obj, new DeleteObjectOptions { Generation = obj.Generation, UserProject = userProject }); } client.DeleteBucket(bucket, new DeleteBucketOptions { UserProject = userProject }); }
public void Dispose() { foreach (BigQueryDataset dataset in _tempDatasets) { var deleteDatasetOptions = new DeleteDatasetOptions() { DeleteContents = true }; dataset.Delete(deleteDatasetOptions); } _storage.DeleteBucket( _bucketName, new DeleteBucketOptions() { DeleteObjects = true } ); Console.SetOut(_consoleOut); }
static void DeleteBucket(string bucketName) { storageClient.DeleteBucket(bucketName); Console.WriteLine($"{bucketName} silindi."); }