2222import org .springframework .http .ResponseEntity ;
2323import org .springframework .web .bind .annotation .GetMapping ;
2424import org .springframework .web .bind .annotation .PathVariable ;
25- import org .springframework .web .bind .annotation .RequestHeader ;
2625import org .springframework .web .bind .annotation .RequestMapping ;
26+ import org .springframework .web .bind .annotation .RequestParam ;
2727import org .springframework .web .bind .annotation .RestController ;
2828
2929/** Endpoints for AI Core AiDeployment operations */
@@ -36,12 +36,7 @@ class DeploymentController {
3636 private static final DeploymentApi CLIENT = new DeploymentApi ();
3737 private static final String RESOURCE_GROUP = "default" ;
3838
39- /**
40- * Create and delete a deployment with the Java specific configuration ID.
41- *
42- * @param configId The configuration id.
43- * @return the deployment deletion response
44- */
39+ /** Create and delete a deployment with the Java specific configuration ID. */
4540 @ Nullable
4641 AiDeploymentDeletionResponse createAndDeleteDeploymentByConfigId (final String configId ) {
4742 final var deployment =
@@ -53,20 +48,14 @@ AiDeploymentDeletionResponse createAndDeleteDeploymentByConfigId(final String co
5348 return CLIENT .delete (RESOURCE_GROUP , deployment .getId ());
5449 }
5550
56- /**
57- * Create and delete a deployment with the Java specific configuration ID.
58- *
59- * @param configId The configuration id.
60- * @param accept The accept header.
61- * @return a response entity with a string representation of the deployment creation response
62- */
51+ /** Create and delete a deployment with the Java specific configuration ID. */
6352 @ GetMapping ("/by-config/{id}/createDelete" )
64- ResponseEntity < Object > createAndDeleteDeploymentByConfigId (
53+ Object createAndDeleteDeploymentByConfigId (
6554 @ Nonnull @ PathVariable ("id" ) final String configId ,
66- @ Nullable @ RequestHeader (value = "accept " , required = false ) final String accept ) {
55+ @ Nullable @ RequestParam (value = "view " , required = false ) final String view ) {
6756 final var response = createAndDeleteDeploymentByConfigId (configId );
68- if ("application/ json" .equals (accept )) {
69- return ResponseEntity . ok (). body ( response ) ;
57+ if ("json" .equals (view )) {
58+ return response ;
7059 }
7160 return ResponseEntity .ok ("Deployment created and will be deleted." );
7261 }
@@ -75,16 +64,11 @@ ResponseEntity<Object> createAndDeleteDeploymentByConfigId(
7564 * Stop all deployments with the Java specific configuration ID.
7665 *
7766 * <p>Only RUNNING deployments can be STOPPED
78- *
79- * @param configId The configuration id.
80- * @param accept The accept header.
81- * @return a response entity with a string representation of the deployment modification response
8267 */
8368 @ GetMapping ("/by-config/{id}/stop" )
84- @ Nonnull
85- ResponseEntity <Object > stopByConfigId (
69+ Object stopByConfigId (
8670 @ Nonnull @ PathVariable ("id" ) final String configId ,
87- @ Nullable @ RequestHeader (value = "accept " , required = false ) final String accept ) {
71+ @ Nullable @ RequestParam (value = "view " , required = false ) final String view ) {
8872 final List <AiDeployment > myDeployments = getAllByConfigId (configId );
8973 log .info ("Found {} deployments to STOP" , myDeployments .size ());
9074
@@ -96,26 +80,21 @@ ResponseEntity<Object> stopByConfigId(
9680 .map (id -> CLIENT .modify (RESOURCE_GROUP , id , modificationRequest ))
9781 .toList ();
9882
99- if ("application/ json" .equals (accept )) {
100- return ResponseEntity . ok (). body ( stoppedDeployments ) ;
83+ if ("json" .equals (view )) {
84+ return stoppedDeployments ;
10185 }
102- return ResponseEntity . ok ( "Deployments under the given config ID stopped." ) ;
86+ return "Deployments under the given config ID stopped." ;
10387 }
10488
10589 /**
10690 * Delete all deployments with the Java specific configuration ID.
10791 *
10892 * <p>Only UNKNOWN and STOPPED deployments can be DELETED
109- *
110- * @param configId The configuration id.
111- * @param accept The accept header.
112- * @return a response entity with a string representation of the deployment deletion response
11393 */
11494 @ GetMapping ("/by-config/{id}/delete" )
115- @ Nonnull
116- ResponseEntity <Object > deleteByConfigId (
95+ Object deleteByConfigId (
11796 @ Nonnull @ PathVariable ("id" ) final String configId ,
118- @ Nullable @ RequestHeader (value = "accept " , required = false ) final String accept ) {
97+ @ Nullable @ RequestParam (value = "view " , required = false ) final String view ) {
11998 final List <AiDeployment > myDeployments = getAllByConfigId (configId );
12099 log .info ("Found {} deployments to DELETE" , myDeployments .size ());
121100
@@ -124,40 +103,27 @@ ResponseEntity<Object> deleteByConfigId(
124103 myDeployments .stream ()
125104 .map (deployment -> CLIENT .delete (RESOURCE_GROUP , deployment .getId ()))
126105 .toList ();
127- if ("application/ json" .equals (accept )) {
128- return ResponseEntity . ok (). body ( responseList ) ;
106+ if ("json" .equals (view )) {
107+ return responseList ;
129108 }
130- return ResponseEntity . ok ( "Deployments under the given config ID deleted." ) ;
109+ return "Deployments under the given config ID deleted." ;
131110 }
132111
133- /**
134- * Get all deployments with the Java specific configuration ID.
135- *
136- * @param configId The configuration id.
137- * @param accept The accept header.
138- * @return a response entity with a string representation of the Java specific deployments
139- */
112+ /** Get all deployments with the Java specific configuration ID. */
140113 @ GetMapping ("/by-config/{id}/getAll" )
141- ResponseEntity < Object > getAllByConfigId (
114+ Object getAllByConfigId (
142115 @ Nonnull @ PathVariable ("id" ) final String configId ,
143- @ Nullable @ RequestHeader (value = "accept " , required = false ) final String accept ) {
116+ @ Nullable @ RequestParam (value = "view " , required = false ) final String view ) {
144117 final var deployments = getAllByConfigId (configId );
145- if ("application/ json" .equals (accept )) {
146- return ResponseEntity . ok (). body ( deployments ) ;
118+ if ("json" .equals (view )) {
119+ return deployments ;
147120 }
148121 final var items =
149122 deployments .stream ().map (AiDeployment ::getId ).collect (Collectors .joining (", " ));
150- return ResponseEntity .ok (
151- "The following Java-specific deployments are available: %s." .formatted (items ));
123+ return "The following Java-specific deployments are available: %s." .formatted (items );
152124 }
153125
154- /**
155- * Get all deployments with the Java specific configuration ID.
156- *
157- * @param configId The configuration id.
158- * @return the Java specific deployments
159- */
160- @ Nonnull
126+ /** Get all deployments with the Java specific configuration ID. */
161127 List <AiDeployment > getAllByConfigId (@ Nonnull @ PathVariable ("id" ) final String configId ) {
162128 final AiDeploymentList deploymentList = CLIENT .query (RESOURCE_GROUP );
163129
@@ -166,34 +132,23 @@ List<AiDeployment> getAllByConfigId(@Nonnull @PathVariable("id") final String co
166132 .toList ();
167133 }
168134
169- /**
170- * Get all deployments, including non-Java specific deployments
171- *
172- * @param accept The accept header.
173- * @return a response entity with a string representation of the Java specific deployments
174- */
135+ /** Get all deployments, including non-Java specific deployments */
175136 @ GetMapping ("/getAll" )
176- @ Nonnull
177- ResponseEntity <Object > getAll (
178- @ Nullable @ RequestHeader (value = "accept" , required = false ) final String accept ) {
137+ Object getAll (@ Nullable @ RequestParam (value = "view" , required = false ) final String view ) {
179138 final var deployments = getAll ();
180- if ("application/ json" .equals (accept )) {
181- return ResponseEntity . ok (). body ( deployments ) ;
139+ if ("json" .equals (view )) {
140+ return deployments ;
182141 }
183142 final var items =
184143 deployments != null
185144 ? deployments .getResources ().stream ()
186145 .map (AiDeployment ::getId )
187146 .collect (Collectors .joining (", " ))
188147 : "" ;
189- return ResponseEntity . ok ( "The following deployments are available: %s." .formatted (items ) );
148+ return "The following deployments are available: %s." .formatted (items );
190149 }
191150
192- /**
193- * Get all deployments
194- *
195- * @return all deployments
196- */
151+ /** Get all deployments */
197152 @ Nullable
198153 AiDeploymentList getAll () {
199154 return CLIENT .query (RESOURCE_GROUP );
@@ -203,9 +158,6 @@ AiDeploymentList getAll() {
203158 * Create a configuration, and deploy it.
204159 *
205160 * <p>This is to be invoked from a unit test.
206- *
207- * @param model The OpenAI model to deploy
208- * @return the deployment creation response
209161 */
210162 @ Nonnull
211163 @ SuppressWarnings ("unused" ) // debug method that doesn't need to be tested
0 commit comments