private Bucket NewBucket(GcsPath gcsPath, NewGcsBucketDynamicParameters dynamicParams) { if (dynamicParams.Project == null) { var property = dynamicParams.GetType().GetProperty(nameof(Project)); ConfigPropertyNameAttribute configPropertyName = (ConfigPropertyNameAttribute)Attribute.GetCustomAttribute( property, typeof(ConfigPropertyNameAttribute)); configPropertyName.SetObjectConfigDefault(property, dynamicParams); } var bucket = new Bucket { Name = gcsPath.Bucket, Location = dynamicParams.Location, StorageClass = dynamicParams.StorageClass }; BucketsResource.InsertRequest insertReq = Service.Buckets.Insert(bucket, dynamicParams.Project); insertReq.PredefinedAcl = dynamicParams.DefaultBucketAcl; insertReq.PredefinedDefaultObjectAcl = dynamicParams.DefaultObjectAcl; Bucket newBucket = insertReq.Execute(); BucketCache.ForceRefresh(); return(newBucket); }
private Bucket NewBucket(GcsPath gcsPath, NewGcsBucketDynamicParameters dynamicParams) { if (dynamicParams.Project == null) { var property = dynamicParams.GetType().GetProperty(nameof(Project)); ConfigPropertyNameAttribute configPropertyName = (ConfigPropertyNameAttribute)Attribute.GetCustomAttribute( property, typeof(ConfigPropertyNameAttribute)); configPropertyName.SetObjectConfigDefault(property, dynamicParams); } var bucket = new Bucket { Name = gcsPath.Bucket, Location = dynamicParams.Location, StorageClass = dynamicParams.StorageClass }; BucketsResource.InsertRequest insertReq = Service.Buckets.Insert(bucket, dynamicParams.Project); insertReq.PredefinedAcl = dynamicParams.DefaultBucketAcl; insertReq.PredefinedDefaultObjectAcl = dynamicParams.DefaultObjectAcl; Bucket newBucket = insertReq.Execute(); // If the bucket cache is not initialized, then don't bother initializing it // because that will cause a long wait time and we may not even know whether // the user needs to use all the other buckets right away. Also, we should not // refresh the whole cache right at this instance (which is why we call // GetValueWithoutUpdate) for the same reason. Dictionary <string, Bucket> bucketDict = BucketCache.GetLastValueWithoutUpdate(); if (bucketDict != null) { bucketDict[newBucket.Name] = newBucket; } return(newBucket); }
internal void ModifyRequest(BucketsResource.InsertRequest request) { if (PredefinedAcl != null) { request.PredefinedAcl = GaxPreconditions.CheckEnumValue((PredefinedAclEnum)PredefinedAcl, nameof(PredefinedAcl)); } if (PredefinedDefaultObjectAcl != null) { request.PredefinedDefaultObjectAcl = GaxPreconditions.CheckEnumValue((PredefinedDefaultObjectAclEnum)PredefinedDefaultObjectAcl, nameof(PredefinedDefaultObjectAcl)); } if (Projection != null) { request.Projection = GaxPreconditions.CheckEnumValue((ProjectionEnum)Projection, nameof(Projection)); } }
protected override void ProcessRecord() { base.ProcessRecord(); var bucket = new Bucket { Name = Name, Location = Location, StorageClass = StorageClass }; BucketsResource.InsertRequest insertReq = Service.Buckets.Insert(bucket, Project); insertReq.PredefinedAcl = DefaultBucketAcl; insertReq.PredefinedDefaultObjectAcl = DefaultObjectAcl; bucket = insertReq.Execute(); WriteObject(bucket); }
protected override void ProcessRecord() { base.ProcessRecord(); var service = GetStorageService(); var bucket = new Google.Apis.Storage.v1.Data.Bucket(); bucket.Name = Name; bucket.Location = Location; bucket.StorageClass = StorageClass; BucketsResource.InsertRequest insertReq = service.Buckets.Insert(bucket, Project); insertReq.PredefinedAcl = DefaultBucketAcl; insertReq.PredefinedDefaultObjectAcl = DefaultObjectAcl; bucket = insertReq.Execute(); WriteObject(bucket); }