Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#1296 from an2x:master
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 602501453
  • Loading branch information
cloud-teleport committed Jan 29, 2024
2 parents 9866990 + a230526 commit 5c0efa9
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing password inputs. */
Expand All @@ -76,6 +79,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing a project ID. */
Expand All @@ -102,6 +108,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing enum options. */
Expand Down Expand Up @@ -131,6 +140,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

public @interface TemplateEnumOption {
Expand Down Expand Up @@ -165,6 +177,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing integer numerical inputs (64 bits). */
Expand All @@ -191,6 +206,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing floating point numerical inputs (32 bits). */
Expand All @@ -217,6 +235,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing floating point numerical inputs (64 bits). */
Expand All @@ -243,6 +264,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing logical inputs. */
Expand Down Expand Up @@ -298,6 +322,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing Cloud Storage folder to write. */
Expand All @@ -324,6 +351,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing Cloud Storage file to read. */
Expand All @@ -350,6 +380,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing Cloud Storage file to write. */
Expand All @@ -376,6 +409,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing a BigQuery table to read/write. */
Expand All @@ -402,6 +438,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing a Pub/Sub topic to read/write. */
Expand All @@ -428,6 +467,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing a Pub/Sub subscription to read. */
Expand All @@ -454,6 +496,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing a duration of time. */
Expand All @@ -480,6 +525,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing an encryption key. */
Expand All @@ -506,6 +554,9 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}

/** Template Parameter containing a date/time input. */
Expand All @@ -532,5 +583,8 @@ public final class TemplateParameter {

/** Example of the parameter. */
String example() default "";

/** Parameter visibility in the UI. */
boolean hiddenUi() default false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.cloud.teleport.plugin.model;

import java.util.HashMap;
import java.util.Map;

/** Image Spec Model. The main payload to communicate parameters to the Dataflow UI. */
Expand Down Expand Up @@ -57,6 +58,20 @@ public void setDefaultEnvironment(Map<String, Object> defaultEnvironment) {
this.defaultEnvironment = defaultEnvironment;
}

public void setAdditionalUserLabel(String label, String value) {
if (defaultEnvironment == null) {
defaultEnvironment = new HashMap<>();
}

@SuppressWarnings("unchecked")
Map<String, String> labels =
(Map<String, String>)
defaultEnvironment.computeIfAbsent(
"additionalUserLabels", k -> new HashMap<String, String>());

labels.put(label, value);
}

public void validate() {
// TODO: what else can be validated here?
ImageSpecMetadata metadata = getMetadata();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ImageSpecParameter {
private String label;
private String helpText;
private Boolean isOptional;
private Boolean hiddenUi;
private List<String> regexes;
private List<ImageSpecParameterEnumOption> enumOptions;
private ImageSpecParameterType paramType;
Expand Down Expand Up @@ -72,11 +73,23 @@ public Boolean isOptional() {
return isOptional;
}

public Boolean hiddenUi() {
return hiddenUi;
}

public void setOptional(Boolean optional) {
if (optional == null || !optional) {
isOptional = null;
this.isOptional = null;
} else {
this.isOptional = true;
}
}

public void setHiddenUi(Boolean hiddenUi) {
if (hiddenUi == null || !hiddenUi) {
this.hiddenUi = null;
} else {
isOptional = true;
this.hiddenUi = true;
}
}

Expand Down Expand Up @@ -129,6 +142,7 @@ public void processParamType(Annotation parameterAnnotation) {
simpleTextParam.helpText(),
simpleTextParam.example());
this.setOptional(simpleTextParam.optional());
this.setHiddenUi(simpleTextParam.hiddenUi());
this.setParamType(ImageSpecParameterType.TEXT);

break;
Expand All @@ -144,6 +158,7 @@ public void processParamType(Annotation parameterAnnotation) {
gcsReadFileParam.helpText(),
gcsReadFileParam.example());
this.setOptional(gcsReadFileParam.optional());
this.setHiddenUi(gcsReadFileParam.hiddenUi());
this.setParamType(ImageSpecParameterType.GCS_READ_FILE);
break;
case "GcsReadFolder":
Expand All @@ -158,6 +173,7 @@ public void processParamType(Annotation parameterAnnotation) {
gcsReadFolderParam.helpText(),
gcsReadFolderParam.example());
this.setOptional(gcsReadFolderParam.optional());
this.setHiddenUi(gcsReadFolderParam.hiddenUi());
this.setParamType(ImageSpecParameterType.GCS_READ_FOLDER);
break;
case "GcsWriteFile":
Expand All @@ -172,6 +188,7 @@ public void processParamType(Annotation parameterAnnotation) {
gcsWriteFileParam.helpText(),
gcsWriteFileParam.example());
this.setOptional(gcsWriteFileParam.optional());
this.setHiddenUi(gcsWriteFileParam.hiddenUi());
this.setParamType(ImageSpecParameterType.GCS_WRITE_FILE);
break;
case "GcsWriteFolder":
Expand All @@ -186,6 +203,7 @@ public void processParamType(Annotation parameterAnnotation) {
gcsWriteFolderParam.helpText(),
gcsWriteFolderParam.example());
this.setOptional(gcsWriteFolderParam.optional());
this.setHiddenUi(gcsWriteFolderParam.hiddenUi());
this.setParamType(ImageSpecParameterType.GCS_WRITE_FOLDER);
break;
case "PubsubSubscription":
Expand All @@ -200,6 +218,7 @@ public void processParamType(Annotation parameterAnnotation) {
pubsubSubscriptionParam.helpText(),
pubsubSubscriptionParam.example());
this.setOptional(pubsubSubscriptionParam.optional());
this.setHiddenUi(pubsubSubscriptionParam.hiddenUi());
this.setParamType(ImageSpecParameterType.PUBSUB_SUBSCRIPTION);
break;
case "PubsubTopic":
Expand All @@ -214,6 +233,7 @@ public void processParamType(Annotation parameterAnnotation) {
pubsubTopicParam.helpText(),
pubsubTopicParam.example());
this.setOptional(pubsubTopicParam.optional());
this.setHiddenUi(pubsubTopicParam.hiddenUi());
this.setParamType(ImageSpecParameterType.PUBSUB_TOPIC);
break;
case "Password":
Expand All @@ -227,6 +247,7 @@ public void processParamType(Annotation parameterAnnotation) {
passwordParam.helpText(),
passwordParam.example());
this.setOptional(passwordParam.optional());
this.setHiddenUi(passwordParam.hiddenUi());
this.setParamType(ImageSpecParameterType.TEXT);
break;
case "ProjectId":
Expand All @@ -241,6 +262,7 @@ public void processParamType(Annotation parameterAnnotation) {
projectIdParam.helpText(),
projectIdParam.example());
this.setOptional(projectIdParam.optional());
this.setHiddenUi(projectIdParam.hiddenUi());
this.setParamType(ImageSpecParameterType.TEXT);
break;
case "Boolean":
Expand All @@ -254,6 +276,7 @@ public void processParamType(Annotation parameterAnnotation) {
booleanParam.helpText(),
booleanParam.example());
this.setOptional(booleanParam.optional());
this.setHiddenUi(booleanParam.hiddenUi());
this.setParamType(ImageSpecParameterType.BOOLEAN);
break;
case "Integer":
Expand All @@ -267,6 +290,7 @@ public void processParamType(Annotation parameterAnnotation) {
integerParam.helpText(),
integerParam.example());
this.setOptional(integerParam.optional());
this.setHiddenUi(integerParam.hiddenUi());
this.setParamType(ImageSpecParameterType.NUMBER);
break;
case "Long":
Expand All @@ -280,6 +304,7 @@ public void processParamType(Annotation parameterAnnotation) {
longParam.helpText(),
longParam.example());
this.setOptional(longParam.optional());
this.setHiddenUi(longParam.hiddenUi());
this.setParamType(ImageSpecParameterType.NUMBER);
break;
case "Float":
Expand All @@ -293,6 +318,7 @@ public void processParamType(Annotation parameterAnnotation) {
floatParam.helpText(),
floatParam.example());
this.setOptional(floatParam.optional());
this.setHiddenUi(floatParam.hiddenUi());
this.setParamType(ImageSpecParameterType.NUMBER);
break;
case "Double":
Expand All @@ -306,6 +332,7 @@ public void processParamType(Annotation parameterAnnotation) {
doubleParam.helpText(),
doubleParam.example());
this.setOptional(doubleParam.optional());
this.setHiddenUi(doubleParam.hiddenUi());
this.setParamType(ImageSpecParameterType.NUMBER);
break;
case "Enum":
Expand All @@ -319,6 +346,7 @@ public void processParamType(Annotation parameterAnnotation) {
enumParam.helpText(),
enumParam.example());
this.setOptional(enumParam.optional());
this.setHiddenUi(enumParam.hiddenUi());
this.setParamType(ImageSpecParameterType.ENUM);
this.setEnumOptions(buildEnumOptions(enumParam));
break;
Expand All @@ -333,6 +361,7 @@ public void processParamType(Annotation parameterAnnotation) {
dateTimeParam.helpText(),
dateTimeParam.example());
this.setOptional(dateTimeParam.optional());
this.setHiddenUi(dateTimeParam.hiddenUi());
this.setParamType(ImageSpecParameterType.TEXT);
break;
case "BigQueryTable":
Expand All @@ -347,6 +376,7 @@ public void processParamType(Annotation parameterAnnotation) {
bigQueryTableParam.helpText(),
bigQueryTableParam.example());
this.setOptional(bigQueryTableParam.optional());
this.setHiddenUi(bigQueryTableParam.hiddenUi());
this.setParamType(ImageSpecParameterType.BIGQUERY_TABLE);
break;
case "KmsEncryptionKey":
Expand All @@ -361,6 +391,7 @@ public void processParamType(Annotation parameterAnnotation) {
kmsEncryptionKeyParam.helpText(),
kmsEncryptionKeyParam.example());
this.setOptional(kmsEncryptionKeyParam.optional());
this.setHiddenUi(kmsEncryptionKeyParam.hiddenUi());
this.setParamType(ImageSpecParameterType.TEXT);
break;
case "Duration":
Expand All @@ -374,6 +405,7 @@ public void processParamType(Annotation parameterAnnotation) {
durationParam.helpText(),
durationParam.example());
this.setOptional(durationParam.optional());
this.setHiddenUi(durationParam.hiddenUi());
this.setParamType(ImageSpecParameterType.TEXT);
break;
default:
Expand Down
Loading

0 comments on commit 5c0efa9

Please sign in to comment.