/** * Convert the given {@link GenericRecord} to {@link HttpOperation} */ public static HttpOperation toHttpOperation(GenericRecord record) { if (record instanceof HttpOperation) { return (HttpOperation) record; } HttpOperation.Builder builder = HttpOperation.newBuilder(); Map<String, String> stringMap = AvroUtils.toStringMap(record.get(HttpConstants.KEYS)); if (stringMap != null) { builder.setKeys(stringMap); } stringMap = AvroUtils.toStringMap(record.get(HttpConstants.QUERY_PARAMS)); if (stringMap != null) { builder.setQueryParams(stringMap); } stringMap = AvroUtils.toStringMap(record.get(HttpConstants.HEADERS)); if (stringMap != null) { builder.setHeaders(stringMap); } Object body = record.get(HttpConstants.BODY); if (body != null) { builder.setBody(body.toString()); } return builder.build(); }
/** * Creates a Builder by copying an existing HttpOperation instance * @param other The existing instance to copy. */ private Builder(org.apache.gobblin.http.HttpOperation other) { super(SCHEMA$); if (isValidValue(fields()[0], other.keys)) { this.keys = data().deepCopy(fields()[0].schema(), other.keys); fieldSetFlags()[0] = true; } if (isValidValue(fields()[1], other.queryParams)) { this.queryParams = data().deepCopy(fields()[1].schema(), other.queryParams); fieldSetFlags()[1] = true; } if (isValidValue(fields()[2], other.headers)) { this.headers = data().deepCopy(fields()[2].schema(), other.headers); fieldSetFlags()[2] = true; } if (isValidValue(fields()[3], other.body)) { this.body = data().deepCopy(fields()[3].schema(), other.body); fieldSetFlags()[3] = true; } }
@Override public HttpOperation build() { try { HttpOperation record = new HttpOperation(); record.keys = fieldSetFlags()[0] ? this.keys : (java.util.Map<java.lang.String,java.lang.String>) defaultValue(fields()[0]); record.queryParams = fieldSetFlags()[1] ? this.queryParams : (java.util.Map<java.lang.String,java.lang.String>) defaultValue(fields()[1]); record.headers = fieldSetFlags()[2] ? this.headers : (java.util.Map<java.lang.String,java.lang.String>) defaultValue(fields()[2]); record.body = fieldSetFlags()[3] ? this.body : (java.lang.String) defaultValue(fields()[3]); return record; } catch (Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
/** * Creates a Builder by copying an existing Builder. * @param other The existing Builder to copy. */ private Builder(org.apache.gobblin.http.HttpOperation.Builder other) { super(other); if (isValidValue(fields()[0], other.keys)) { this.keys = data().deepCopy(fields()[0].schema(), other.keys); fieldSetFlags()[0] = true; } if (isValidValue(fields()[1], other.queryParams)) { this.queryParams = data().deepCopy(fields()[1].schema(), other.queryParams); fieldSetFlags()[1] = true; } if (isValidValue(fields()[2], other.headers)) { this.headers = data().deepCopy(fields()[2].schema(), other.headers); fieldSetFlags()[2] = true; } if (isValidValue(fields()[3], other.body)) { this.body = data().deepCopy(fields()[3].schema(), other.body); fieldSetFlags()[3] = true; } }
/** * Convert the given {@link GenericRecord} to {@link HttpOperation} */ public static HttpOperation toHttpOperation(GenericRecord record) { if (record instanceof HttpOperation) { return (HttpOperation) record; } HttpOperation.Builder builder = HttpOperation.newBuilder(); Map<String, String> stringMap = AvroUtils.toStringMap(record.get(HttpConstants.KEYS)); if (stringMap != null) { builder.setKeys(stringMap); } stringMap = AvroUtils.toStringMap(record.get(HttpConstants.QUERY_PARAMS)); if (stringMap != null) { builder.setQueryParams(stringMap); } stringMap = AvroUtils.toStringMap(record.get(HttpConstants.HEADERS)); if (stringMap != null) { builder.setHeaders(stringMap); } Object body = record.get(HttpConstants.BODY); if (body != null) { builder.setBody(body.toString()); } return builder.build(); }
/** * Creates a Builder by copying an existing HttpOperation instance * @param other The existing instance to copy. */ private Builder(org.apache.gobblin.http.HttpOperation other) { super(SCHEMA$); if (isValidValue(fields()[0], other.keys)) { this.keys = data().deepCopy(fields()[0].schema(), other.keys); fieldSetFlags()[0] = true; } if (isValidValue(fields()[1], other.queryParams)) { this.queryParams = data().deepCopy(fields()[1].schema(), other.queryParams); fieldSetFlags()[1] = true; } if (isValidValue(fields()[2], other.headers)) { this.headers = data().deepCopy(fields()[2].schema(), other.headers); fieldSetFlags()[2] = true; } if (isValidValue(fields()[3], other.body)) { this.body = data().deepCopy(fields()[3].schema(), other.body); fieldSetFlags()[3] = true; } }
@Override public HttpOperation build() { try { HttpOperation record = new HttpOperation(); record.keys = fieldSetFlags()[0] ? this.keys : (java.util.Map<java.lang.String,java.lang.String>) defaultValue(fields()[0]); record.queryParams = fieldSetFlags()[1] ? this.queryParams : (java.util.Map<java.lang.String,java.lang.String>) defaultValue(fields()[1]); record.headers = fieldSetFlags()[2] ? this.headers : (java.util.Map<java.lang.String,java.lang.String>) defaultValue(fields()[2]); record.body = fieldSetFlags()[3] ? this.body : (java.lang.String) defaultValue(fields()[3]); return record; } catch (Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
/** * Clears the value of the 'headers' field. * header key/value pairs. * @return This builder. */ public org.apache.gobblin.http.HttpOperation.Builder clearHeaders() { headers = null; fieldSetFlags()[2] = false; return this; }
/** * Clears the value of the 'queryParams' field. * query parameters. * @return This builder. */ public org.apache.gobblin.http.HttpOperation.Builder clearQueryParams() { queryParams = null; fieldSetFlags()[1] = false; return this; }
/** * Creates a new HttpOperation RecordBuilder by copying an existing Builder. * @param other The existing builder to copy. * @return A new HttpOperation RecordBuilder */ public static org.apache.gobblin.http.HttpOperation.Builder newBuilder(org.apache.gobblin.http.HttpOperation.Builder other) { return new org.apache.gobblin.http.HttpOperation.Builder(other); }
/** * Checks whether the 'headers' field has been set. * header key/value pairs. * @return True if the 'headers' field has been set, false otherwise. */ public boolean hasHeaders() { return fieldSetFlags()[2]; }
/** * Checks whether the 'queryParams' field has been set. * query parameters. * @return True if the 'queryParams' field has been set, false otherwise. */ public boolean hasQueryParams() { return fieldSetFlags()[1]; }
/** * Creates a new HttpOperation RecordBuilder by copying an existing HttpOperation instance. * @param other The existing instance to copy. * @return A new HttpOperation RecordBuilder */ public static org.apache.gobblin.http.HttpOperation.Builder newBuilder(org.apache.gobblin.http.HttpOperation other) { return new org.apache.gobblin.http.HttpOperation.Builder(other); }
/** * Creates a new HttpOperation RecordBuilder. * @return A new HttpOperation RecordBuilder */ public static org.apache.gobblin.http.HttpOperation.Builder newBuilder() { return new org.apache.gobblin.http.HttpOperation.Builder(); }
/** * Sets the value of the 'headers' field. * header key/value pairs. * @param value The value of 'headers'. * @return This builder. */ public org.apache.gobblin.http.HttpOperation.Builder setHeaders(java.util.Map<java.lang.String,java.lang.String> value) { validate(fields()[2], value); this.headers = value; fieldSetFlags()[2] = true; return this; }
/** * Clears the value of the 'keys' field. * Key of the resource on which the operation is executed. Complex key resources are identified by more than one key. Hence this field is a map as opposed to a string. The map is used to interpolate the url template in job spec. * @return This builder. */ public org.apache.gobblin.http.HttpOperation.Builder clearKeys() { keys = null; fieldSetFlags()[0] = false; return this; }
/** * Checks whether the 'keys' field has been set. * Key of the resource on which the operation is executed. Complex key resources are identified by more than one key. Hence this field is a map as opposed to a string. The map is used to interpolate the url template in job spec. * @return True if the 'keys' field has been set, false otherwise. */ public boolean hasKeys() { return fieldSetFlags()[0]; }
/** * Checks whether the 'body' field has been set. * body of the http request. It must be either a plain string or a json string. * @return True if the 'body' field has been set, false otherwise. */ public boolean hasBody() { return fieldSetFlags()[3]; }
/** * Sets the value of the 'body' field. * body of the http request. It must be either a plain string or a json string. * @param value The value of 'body'. * @return This builder. */ public org.apache.gobblin.http.HttpOperation.Builder setBody(java.lang.String value) { validate(fields()[3], value); this.body = value; fieldSetFlags()[3] = true; return this; }
/** * Sets the value of the 'queryParams' field. * query parameters. * @param value The value of 'queryParams'. * @return This builder. */ public org.apache.gobblin.http.HttpOperation.Builder setQueryParams(java.util.Map<java.lang.String,java.lang.String> value) { validate(fields()[1], value); this.queryParams = value; fieldSetFlags()[1] = true; return this; }