|
| 1 | +/* |
| 2 | +* Copyright (c) 2026 SAP SE or an SAP affiliate company. All rights reserved. |
| 3 | +*/ |
| 4 | + |
| 5 | +package com.sap.cloud.sdk.datamodel.openapi.apache.petstore.api; |
| 6 | + |
| 7 | +import java.util.ArrayList; |
| 8 | +import java.util.HashMap; |
| 9 | +import java.util.List; |
| 10 | +import java.util.Map; |
| 11 | +import java.util.StringJoiner; |
| 12 | + |
| 13 | +import javax.annotation.Nonnull; |
| 14 | +import javax.annotation.Nullable; |
| 15 | + |
| 16 | +import com.fasterxml.jackson.core.type.TypeReference; |
| 17 | +import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; |
| 18 | +import com.sap.cloud.sdk.datamodel.openapi.apache.petstore.model.Pet; |
| 19 | +import com.sap.cloud.sdk.datamodel.openapi.apache.petstore.model.PetInput; |
| 20 | +import com.sap.cloud.sdk.services.openapi.apache.ApiClient; |
| 21 | +import com.sap.cloud.sdk.services.openapi.apache.BaseApi; |
| 22 | +import com.sap.cloud.sdk.services.openapi.apache.OpenApiResponse; |
| 23 | +import com.sap.cloud.sdk.services.openapi.apache.Pair; |
| 24 | +import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException; |
| 25 | + |
| 26 | +/** |
| 27 | + * Swagger Petstore in version 1.0.0. |
| 28 | + * |
| 29 | + * A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification |
| 30 | + */ |
| 31 | +public class DefaultApi extends BaseApi |
| 32 | +{ |
| 33 | + |
| 34 | + /** |
| 35 | + * Instantiates this API class to invoke operations on the Swagger Petstore |
| 36 | + */ |
| 37 | + public DefaultApi() |
| 38 | + { |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Instantiates this API class to invoke operations on the Swagger Petstore. |
| 43 | + * |
| 44 | + * @param httpDestination |
| 45 | + * The destination that API should be used with |
| 46 | + */ |
| 47 | + public DefaultApi( @Nonnull final Destination httpDestination ) |
| 48 | + { |
| 49 | + super(httpDestination); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Instantiates this API class to invoke operations on the Swagger Petstore based on a given {@link ApiClient}. |
| 54 | + * |
| 55 | + * @param apiClient |
| 56 | + * ApiClient to invoke the API on |
| 57 | + */ |
| 58 | + public DefaultApi( @Nonnull final ApiClient apiClient ) |
| 59 | + { |
| 60 | + super(apiClient); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * <p> |
| 65 | + * <p> |
| 66 | + * Creates a new pet in the store. Duplicates are allowed |
| 67 | + * <p> |
| 68 | + * <b>200</b> - pet response |
| 69 | + * <p> |
| 70 | + * <b>0</b> - unexpected error |
| 71 | + * |
| 72 | + * @param pet |
| 73 | + * Pet to add to the store |
| 74 | + * @return Pet |
| 75 | + * @throws OpenApiRequestException |
| 76 | + * if an error occurs while attempting to invoke the API |
| 77 | + */ |
| 78 | + @Nonnull |
| 79 | + public Pet addPet( @Nonnull final PetInput pet ) |
| 80 | + throws OpenApiRequestException |
| 81 | + { |
| 82 | + final Object localVarPostBody = pet; |
| 83 | + |
| 84 | + // verify the required parameter 'pet' is set |
| 85 | + if( pet == null ) { |
| 86 | + throw new OpenApiRequestException("Missing the required parameter 'pet' when calling addPet") |
| 87 | + .statusCode(400); |
| 88 | + } |
| 89 | + |
| 90 | + // create path and map variables |
| 91 | + final String localVarPath = "/pets"; |
| 92 | + |
| 93 | + final StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); |
| 94 | + String localVarQueryParameterBaseName; |
| 95 | + final List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 96 | + final List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); |
| 97 | + final Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 98 | + final Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 99 | + |
| 100 | + final String[] localVarAccepts = { "application/json" }; |
| 101 | + final String localVarAccept = ApiClient.selectHeaderAccept(localVarAccepts); |
| 102 | + |
| 103 | + final String[] localVarContentTypes = { "application/json" }; |
| 104 | + final String localVarContentType = ApiClient.selectHeaderContentType(localVarContentTypes); |
| 105 | + |
| 106 | + final TypeReference<Pet> localVarReturnType = new TypeReference<Pet>() |
| 107 | + { |
| 108 | + }; |
| 109 | + return apiClient |
| 110 | + .invokeAPI( |
| 111 | + localVarPath, |
| 112 | + "POST", |
| 113 | + localVarQueryParams, |
| 114 | + localVarCollectionQueryParams, |
| 115 | + localVarQueryStringJoiner.toString(), |
| 116 | + localVarPostBody, |
| 117 | + localVarHeaderParams, |
| 118 | + localVarFormParams, |
| 119 | + localVarAccept, |
| 120 | + localVarContentType, |
| 121 | + localVarReturnType); |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * <p> |
| 126 | + * <p> |
| 127 | + * deletes a single pet based on the ID supplied |
| 128 | + * <p> |
| 129 | + * <b>204</b> - pet deleted |
| 130 | + * <p> |
| 131 | + * <b>0</b> - unexpected error |
| 132 | + * |
| 133 | + * @param id |
| 134 | + * ID of pet to delete |
| 135 | + * @return An OpenApiResponse containing the status code of the HttpResponse. |
| 136 | + * @throws OpenApiRequestException |
| 137 | + * if an error occurs while attempting to invoke the API |
| 138 | + */ |
| 139 | + @Nonnull |
| 140 | + public OpenApiResponse deletePet( @Nonnull final Long id ) |
| 141 | + throws OpenApiRequestException |
| 142 | + { |
| 143 | + final Object localVarPostBody = null; |
| 144 | + |
| 145 | + // verify the required parameter 'id' is set |
| 146 | + if( id == null ) { |
| 147 | + throw new OpenApiRequestException("Missing the required parameter 'id' when calling deletePet") |
| 148 | + .statusCode(400); |
| 149 | + } |
| 150 | + |
| 151 | + // create path and map variables |
| 152 | + final String localVarPath = |
| 153 | + "/pets/{id}".replaceAll("\\{" + "id" + "\\}", ApiClient.escapeString(ApiClient.parameterToString(id))); |
| 154 | + |
| 155 | + final StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); |
| 156 | + String localVarQueryParameterBaseName; |
| 157 | + final List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 158 | + final List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); |
| 159 | + final Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 160 | + final Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 161 | + |
| 162 | + final String[] localVarAccepts = { "application/json" }; |
| 163 | + final String localVarAccept = ApiClient.selectHeaderAccept(localVarAccepts); |
| 164 | + |
| 165 | + final String[] localVarContentTypes = { |
| 166 | + |
| 167 | + }; |
| 168 | + final String localVarContentType = ApiClient.selectHeaderContentType(localVarContentTypes); |
| 169 | + |
| 170 | + final TypeReference<OpenApiResponse> localVarReturnType = new TypeReference<OpenApiResponse>() |
| 171 | + { |
| 172 | + }; |
| 173 | + return apiClient |
| 174 | + .invokeAPI( |
| 175 | + localVarPath, |
| 176 | + "DELETE", |
| 177 | + localVarQueryParams, |
| 178 | + localVarCollectionQueryParams, |
| 179 | + localVarQueryStringJoiner.toString(), |
| 180 | + localVarPostBody, |
| 181 | + localVarHeaderParams, |
| 182 | + localVarFormParams, |
| 183 | + localVarAccept, |
| 184 | + localVarContentType, |
| 185 | + localVarReturnType); |
| 186 | + } |
| 187 | + |
| 188 | + /** |
| 189 | + * <p> |
| 190 | + * <p> |
| 191 | + * Returns a user based on a single ID, if the user does not have access to the pet |
| 192 | + * <p> |
| 193 | + * <b>200</b> - pet response |
| 194 | + * <p> |
| 195 | + * <b>0</b> - unexpected error |
| 196 | + * |
| 197 | + * @param id |
| 198 | + * ID of pet to fetch |
| 199 | + * @return Pet |
| 200 | + * @throws OpenApiRequestException |
| 201 | + * if an error occurs while attempting to invoke the API |
| 202 | + */ |
| 203 | + @Nonnull |
| 204 | + public Pet findPetById( @Nonnull final Long id ) |
| 205 | + throws OpenApiRequestException |
| 206 | + { |
| 207 | + final Object localVarPostBody = null; |
| 208 | + |
| 209 | + // verify the required parameter 'id' is set |
| 210 | + if( id == null ) { |
| 211 | + throw new OpenApiRequestException("Missing the required parameter 'id' when calling findPetById") |
| 212 | + .statusCode(400); |
| 213 | + } |
| 214 | + |
| 215 | + // create path and map variables |
| 216 | + final String localVarPath = |
| 217 | + "/pets/{id}".replaceAll("\\{" + "id" + "\\}", ApiClient.escapeString(ApiClient.parameterToString(id))); |
| 218 | + |
| 219 | + final StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); |
| 220 | + String localVarQueryParameterBaseName; |
| 221 | + final List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 222 | + final List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); |
| 223 | + final Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 224 | + final Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 225 | + |
| 226 | + final String[] localVarAccepts = { "application/json", "application/xml", "text/xml", "text/html" }; |
| 227 | + final String localVarAccept = ApiClient.selectHeaderAccept(localVarAccepts); |
| 228 | + |
| 229 | + final String[] localVarContentTypes = { |
| 230 | + |
| 231 | + }; |
| 232 | + final String localVarContentType = ApiClient.selectHeaderContentType(localVarContentTypes); |
| 233 | + |
| 234 | + final TypeReference<Pet> localVarReturnType = new TypeReference<Pet>() |
| 235 | + { |
| 236 | + }; |
| 237 | + return apiClient |
| 238 | + .invokeAPI( |
| 239 | + localVarPath, |
| 240 | + "GET", |
| 241 | + localVarQueryParams, |
| 242 | + localVarCollectionQueryParams, |
| 243 | + localVarQueryStringJoiner.toString(), |
| 244 | + localVarPostBody, |
| 245 | + localVarHeaderParams, |
| 246 | + localVarFormParams, |
| 247 | + localVarAccept, |
| 248 | + localVarContentType, |
| 249 | + localVarReturnType); |
| 250 | + } |
| 251 | + |
| 252 | + /** |
| 253 | + * <p> |
| 254 | + * <p> |
| 255 | + * Returns all pets from the system that the user has access to |
| 256 | + * <p> |
| 257 | + * <b>200</b> - pet response |
| 258 | + * <p> |
| 259 | + * <b>0</b> - unexpected error |
| 260 | + * |
| 261 | + * @param tags |
| 262 | + * (optional) tags to filter by |
| 263 | + * @param limit |
| 264 | + * (optional) maximum number of results to return |
| 265 | + * @return List<Pet> |
| 266 | + * @throws OpenApiRequestException |
| 267 | + * if an error occurs while attempting to invoke the API |
| 268 | + */ |
| 269 | + @Nonnull |
| 270 | + public List<Pet> findPets( @Nullable final List<String> tags, @Nullable final Integer limit ) |
| 271 | + throws OpenApiRequestException |
| 272 | + { |
| 273 | + final Object localVarPostBody = null; |
| 274 | + |
| 275 | + // create path and map variables |
| 276 | + final String localVarPath = "/pets"; |
| 277 | + |
| 278 | + final StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); |
| 279 | + String localVarQueryParameterBaseName; |
| 280 | + final List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 281 | + final List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); |
| 282 | + final Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 283 | + final Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 284 | + |
| 285 | + localVarCollectionQueryParams.addAll(ApiClient.parameterToPairs("csv", "tags", tags)); |
| 286 | + localVarQueryParams.addAll(ApiClient.parameterToPair("limit", limit)); |
| 287 | + |
| 288 | + final String[] localVarAccepts = { "application/json", "application/xml", "text/xml", "text/html" }; |
| 289 | + final String localVarAccept = ApiClient.selectHeaderAccept(localVarAccepts); |
| 290 | + |
| 291 | + final String[] localVarContentTypes = { |
| 292 | + |
| 293 | + }; |
| 294 | + final String localVarContentType = ApiClient.selectHeaderContentType(localVarContentTypes); |
| 295 | + |
| 296 | + final TypeReference<List<Pet>> localVarReturnType = new TypeReference<List<Pet>>() |
| 297 | + { |
| 298 | + }; |
| 299 | + return apiClient |
| 300 | + .invokeAPI( |
| 301 | + localVarPath, |
| 302 | + "GET", |
| 303 | + localVarQueryParams, |
| 304 | + localVarCollectionQueryParams, |
| 305 | + localVarQueryStringJoiner.toString(), |
| 306 | + localVarPostBody, |
| 307 | + localVarHeaderParams, |
| 308 | + localVarFormParams, |
| 309 | + localVarAccept, |
| 310 | + localVarContentType, |
| 311 | + localVarReturnType); |
| 312 | + } |
| 313 | + |
| 314 | + /** |
| 315 | + * <p> |
| 316 | + * <p> |
| 317 | + * Returns all pets from the system that the user has access to |
| 318 | + * <p> |
| 319 | + * <b>200</b> - pet response |
| 320 | + * <p> |
| 321 | + * <b>0</b> - unexpected error |
| 322 | + * |
| 323 | + * @return List<Pet> |
| 324 | + * @throws OpenApiRequestException |
| 325 | + * if an error occurs while attempting to invoke the API |
| 326 | + */ |
| 327 | + @Nonnull |
| 328 | + public List<Pet> findPets() |
| 329 | + throws OpenApiRequestException |
| 330 | + { |
| 331 | + return findPets(null, null); |
| 332 | + } |
| 333 | +} |
0 commit comments