protected override void ProcessRecord() { base.ProcessRecord(); if (ParameterSetName == ParameterSetNames.SingleBucket) { BucketsResource.GetRequest req = Service.Buckets.Get(Name); req.Projection = BucketsResource.GetRequest.ProjectionEnum.Full; try { Bucket bucket = req.Execute(); WriteObject(bucket); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound) { ErrorRecord errorRecord = new ErrorRecord( new ItemNotFoundException($"Storage bucket '{Name}' does not exist."), "BucketNotFound", ErrorCategory.ObjectNotFound, Name); ThrowTerminatingError(errorRecord); } } if (ParameterSetName == ParameterSetNames.BucketsByProject) { var req = Service.Buckets.List(Project); req.Projection = BucketsResource.ListRequest.ProjectionEnum.Full; Buckets buckets = req.Execute(); WriteObject(buckets.Items, true); } }
protected override void ProcessRecord() { base.ProcessRecord(); BucketsResource.GetRequest req = Service.Buckets.Get(this.Name); req.Projection = BucketsResource.GetRequest.ProjectionEnum.Full; Bucket bucket = req.Execute(); // TODO(chrsmith): Follow up. Is this a bug? How to remove an object? bucket.Website = new Bucket.WebsiteData(); // Keep uninitialized to clear fields. BucketsResource.PatchRequest req2 = Service.Buckets.Patch(bucket, this.Name); req2.Projection = BucketsResource.PatchRequest.ProjectionEnum.Full; req2.Execute(); this.WriteObject(bucket); }
protected override void ProcessRecord() { base.ProcessRecord(); BucketsResource.GetRequest req = Service.Buckets.Get(this.Name); req.Projection = BucketsResource.GetRequest.ProjectionEnum.Full; Bucket bucket = req.Execute(); // TODO(chrsmith): Follow up. Is this a bug? How can you remove an object? // Logging doesn't work for patch-with-empty-obj. bucket.Logging = null; BucketsResource.UpdateRequest req2 = Service.Buckets.Update(bucket, this.Name); req2.Projection = BucketsResource.UpdateRequest.ProjectionEnum.Full; req2.Execute(); this.WriteObject(bucket); }
protected override void ProcessRecord() { base.ProcessRecord(); if (ParameterSetName == ParameterSetNames.SingleBucket) { BucketsResource.GetRequest req = Service.Buckets.Get(Name); req.Projection = BucketsResource.GetRequest.ProjectionEnum.Full; Bucket bucket = req.Execute(); WriteObject(bucket); } if (ParameterSetName == ParameterSetNames.BucketsByProject) { var req = Service.Buckets.List(Project); req.Projection = BucketsResource.ListRequest.ProjectionEnum.Full; Buckets buckets = req.Execute(); WriteObject(buckets.Items, true); } }