/// <summary> /// Validates that the given Bucket has a "somewhat valid" (no URI encoding required) bucket name. /// </summary> /// <param name="bucket">Bucket to validate</param> /// <param name="paramName">The parameter name in the calling method</param> private void ValidateBucket(Bucket bucket, string paramName) { GaxRestPreconditions.CheckNotNull(bucket, paramName); GaxRestPreconditions.CheckArgument(bucket.Name != null, paramName, "Bucket must have a name"); GaxRestPreconditions.CheckArgument(ValidBucketName.IsMatch(bucket.Name), paramName, "Invalid bucket name '{0}' - see https://cloud.google.com/storage/docs/bucket-naming", bucket.Name); }
private BucketsResource.UpdateRequest CreateUpdateBucketRequest(Bucket bucket, UpdateBucketOptions options) { ValidateBucket(bucket, nameof(bucket)); GaxRestPreconditions.CheckArgument(bucket.Acl != null, nameof(bucket), "The Acl property of the bucket to update is null"); var request = Service.Buckets.Update(bucket, bucket.Name); options?.ModifyRequest(request); return(request); }
private ObjectsResource.PatchRequest CreatePatchObjectRequest(Object obj, PatchObjectOptions options) { GaxRestPreconditions.CheckNotNull(obj, nameof(obj)); GaxRestPreconditions.CheckArgument(obj.Bucket != null, nameof(obj), "The Bucket property of the object to update is null"); GaxRestPreconditions.CheckArgument(obj.Name != null, nameof(obj), "The Name property of the object to update is null"); var request = Service.Objects.Patch(obj, obj.Bucket, obj.Name); options?.ModifyRequest(request); return(request); }
/// <summary> /// Validates that the given Object has a "somewhat valid" (no URI encoding required) bucket name and an object name. /// </summary> /// <param name="obj">Object to validate</param> /// <param name="paramName">The parameter name in the calling method</param> private void ValidateObject(Object obj, string paramName) { GaxRestPreconditions.CheckNotNull(obj, paramName); GaxRestPreconditions.CheckArgument( obj.Name != null && obj.Bucket != null, paramName, "Object must have a name and bucket"); GaxRestPreconditions.CheckArgument(ValidBucketName.IsMatch(obj.Bucket), paramName, "Object bucket '{0}' is invalid", obj.Bucket); }
/// <summary> /// Creates a field with the specified details, and adds it to the schema being built. /// </summary> /// <param name="name">The name of the field. Must be a valid field name.</param> /// <param name="type">The type of the field. Must be a defined member within <see cref="BigqueryDbType"/>, other than <c>Record</c>.</param> /// <param name="mode">The mode of the field. Must be a defined member within <see cref="FieldMode"/>.</param> /// <param name="description">The description of the field. May be null.</param> public void Add(string name, BigqueryDbType type, FieldMode mode = FieldMode.Nullable, string description = null) { ValidateFieldName(name, nameof(name)); GaxRestPreconditions.CheckArgument(type != BigqueryDbType.Record, nameof(type), "Record fields must be specified with their schema"); Add(new TableFieldSchema { Name = name, Type = EnumMap <BigqueryDbType> .ToApiValue(type, nameof(type)), Mode = EnumMap <FieldMode> .ToApiValue(mode, nameof(mode)), Description = description, }); }
/// <inheritdoc /> public override void Insert(TableReference tableReference, IEnumerable <InsertRow> rows, InsertOptions options = null) { GaxRestPreconditions.CheckNotNull(tableReference, nameof(tableReference)); GaxRestPreconditions.CheckNotNull(rows, nameof(rows)); var body = new TableDataInsertAllRequest { Rows = rows.Select(row => { GaxRestPreconditions.CheckArgument(row != null, nameof(rows), "Entries must not be null"); return(row.ToRowsData()); }).ToList() }; options?.ModifyRequest(body); var request = Service.Tabledata.InsertAll(body, tableReference.ProjectId, tableReference.DatasetId, tableReference.TableId); var response = request.Execute(); HandleInsertAllResponse(response); }
internal void Validate() { GaxRestPreconditions.CheckArgument(Timeout == null || Deadline == null, "options", $"Cannot set both {nameof(Timeout)} and {nameof(Deadline)} to non-null values"); }
internal static void ValidateFieldName(string name, string paramName) { GaxRestPreconditions.CheckNotNull(name, paramName); GaxRestPreconditions.CheckArgument(s_fieldNamePattern.IsMatch(name), paramName, "Invalid field name '{0}'", name); }