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); }
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; }