2323import com .google .cloud .automl .v1beta1 .Model ;
2424import com .google .cloud .automl .v1beta1 .ModelName ;
2525import com .google .longrunning .Operation ;
26- import com .google .protobuf .Empty ;
2726import java .io .IOException ;
2827import java .io .PrintStream ;
29- import java .util .concurrent .ExecutionException ;
3028import net .sourceforge .argparse4j .ArgumentParsers ;
3129import net .sourceforge .argparse4j .inf .ArgumentParser ;
3230import net .sourceforge .argparse4j .inf .ArgumentParserException ;
@@ -83,65 +81,6 @@ public static void listModels(String projectId, String computeRegion, String fil
8381 }
8482 // [END automl_translate_list_models]
8583
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-
14584 // [START automl_translate_get_operation_status]
14685 /**
14786 * Demonstrates using the AutoML client to get operation status.
@@ -179,12 +118,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
179118 Subparser listModelParser = subparsers .addParser ("list_models" );
180119 listModelParser .addArgument ("filter" ).nargs ("?" ).setDefault ("" );
181120
182- Subparser getModelParser = subparsers .addParser ("get_model" );
183- getModelParser .addArgument ("modelId" );
184-
185- Subparser deleteModelParser = subparsers .addParser ("delete_model" );
186- deleteModelParser .addArgument ("modelId" );
187-
188121 Subparser getOperationStatusParser = subparsers .addParser ("get_operation_status" );
189122 getOperationStatusParser .addArgument ("operationFullId" );
190123
@@ -197,12 +130,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
197130 if (ns .get ("command" ).equals ("list_models" )) {
198131 listModels (projectId , computeRegion , ns .getString ("filter" ));
199132 }
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- }
206133 if (ns .get ("command" ).equals ("get_operation_status" )) {
207134 getOperationStatus (ns .getString ("operationFullId" ));
208135 }
0 commit comments