23
23
import com .google .cloud .automl .v1beta1 .Model ;
24
24
import com .google .cloud .automl .v1beta1 .ModelName ;
25
25
import com .google .longrunning .Operation ;
26
- import com .google .protobuf .Empty ;
27
26
import java .io .IOException ;
28
27
import java .io .PrintStream ;
29
- import java .util .concurrent .ExecutionException ;
30
28
import net .sourceforge .argparse4j .ArgumentParsers ;
31
29
import net .sourceforge .argparse4j .inf .ArgumentParser ;
32
30
import net .sourceforge .argparse4j .inf .ArgumentParserException ;
@@ -83,65 +81,6 @@ public static void listModels(String projectId, String computeRegion, String fil
83
81
}
84
82
// [END automl_translate_list_models]
85
83
86
- // [START automl_translate_get_model]
87
- /**
88
- * Demonstrates using the AutoML client to get model details.
89
- *
90
- * @param projectId the Id of the project.
91
- * @param computeRegion the Region name.
92
- * @param modelId the Id of the model.
93
- * @throws IOException on Input/Output errors.
94
- */
95
- public static void getModel (String projectId , String computeRegion , String modelId )
96
- throws IOException {
97
- // Instantiates a client
98
- try (AutoMlClient client = AutoMlClient .create ()) {
99
-
100
- // Get the full path of the model.
101
- ModelName modelFullId = ModelName .of (projectId , computeRegion , modelId );
102
-
103
- // Get complete detail of the model.
104
- Model model = client .getModel (modelFullId );
105
-
106
- // Display the model information.
107
- System .out .println (String .format ("Model name: %s" , model .getName ()));
108
- System .out .println (
109
- String .format (
110
- "Model id: %s" , model .getName ().split ("/" )[model .getName ().split ("/" ).length - 1 ]));
111
- System .out .println (String .format ("Model display name: %s" , model .getDisplayName ()));
112
- System .out .println ("Model create time:" );
113
- System .out .println (String .format ("\t seconds: %s" , model .getCreateTime ().getSeconds ()));
114
- System .out .println (String .format ("\t nanos: %s" , model .getCreateTime ().getNanos ()));
115
- System .out .println (String .format ("Model deployment state: %s" , model .getDeploymentState ()));
116
- }
117
- }
118
- // [END automl_translate_get_model]
119
-
120
- // [START automl_translate_delete_model]
121
- /**
122
- * Demonstrates using the AutoML client to delete a model.
123
- *
124
- * @param projectId the Id of the project.
125
- * @param computeRegion the Region name.
126
- * @param modelId the Id of the model.
127
- * @throws Exception on AutoML Client errors
128
- */
129
- public static void deleteModel (String projectId , String computeRegion , String modelId )
130
- throws InterruptedException , ExecutionException , IOException {
131
- // Instantiates a client
132
- try (AutoMlClient client = AutoMlClient .create ()) {
133
-
134
- // Get the full path of the model.
135
- ModelName modelFullId = ModelName .of (projectId , computeRegion , modelId );
136
-
137
- // Delete a model.
138
- Empty response = client .deleteModelAsync (modelFullId ).get ();
139
-
140
- System .out .println ("Model deletion started..." );
141
- }
142
- }
143
- // [END automl_translate_delete_model]
144
-
145
84
// [START automl_translate_get_operation_status]
146
85
/**
147
86
* Demonstrates using the AutoML client to get operation status.
@@ -179,12 +118,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
179
118
Subparser listModelParser = subparsers .addParser ("list_models" );
180
119
listModelParser .addArgument ("filter" ).nargs ("?" ).setDefault ("" );
181
120
182
- Subparser getModelParser = subparsers .addParser ("get_model" );
183
- getModelParser .addArgument ("modelId" );
184
-
185
- Subparser deleteModelParser = subparsers .addParser ("delete_model" );
186
- deleteModelParser .addArgument ("modelId" );
187
-
188
121
Subparser getOperationStatusParser = subparsers .addParser ("get_operation_status" );
189
122
getOperationStatusParser .addArgument ("operationFullId" );
190
123
@@ -197,12 +130,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
197
130
if (ns .get ("command" ).equals ("list_models" )) {
198
131
listModels (projectId , computeRegion , ns .getString ("filter" ));
199
132
}
200
- if (ns .get ("command" ).equals ("get_model" )) {
201
- getModel (projectId , computeRegion , ns .getString ("modelId" ));
202
- }
203
- if (ns .get ("command" ).equals ("delete_model" )) {
204
- deleteModel (projectId , computeRegion , ns .getString ("modelId" ));
205
- }
206
133
if (ns .get ("command" ).equals ("get_operation_status" )) {
207
134
getOperationStatus (ns .getString ("operationFullId" ));
208
135
}
0 commit comments