@@ -105,74 +105,8 @@ defaultClient.setClientConfig(clientConfig);
105
105
{ {/jersey2} }
106
106
## Getting Started
107
107
108
- Please follow the [installation](#installation) instruction and execute the following Java code:
108
+ See the [{ {serviceId } } examples]( { {scmUrl } }/tree/main/examples/ { {serviceId } }/src/main/java/cloud/stackit/sdk/ { {serviceId } }/examples).
109
109
110
- ```java
111
- { {#apiInfo} }{ {#apis} }{ {#-first} }{ {#operations} }{ {#operation} }{ {#-first} }
112
- import { {{invokerPackage} }}.*;
113
- import { {{invokerPackage} }}.auth.*;
114
- import { {{modelPackage} }}.*;
115
- import { {{package} }}.{ {{classname} }};
116
-
117
- public class { {{classname} }}Example {
118
-
119
- public static void main(String[] args) {
120
- ApiClient defaultClient = Configuration.getDefaultApiClient();
121
- defaultClient.setBasePath(" {{{basePath}}}" );
122
- {{#hasAuthMethods} }{ {#authMethods} }{ {#isBasic} }{ {#isBasicBasic} }
123
- // Configure HTTP basic authorization: { {{name} }}
124
- HttpBasicAuth { {{name} }} = (HttpBasicAuth) defaultClient.getAuthentication("{ {{name} }}");
125
- { {{name} }}.setUsername("YOUR USERNAME");
126
- { {{name} }}.setPassword("YOUR PASSWORD");{ {/isBasicBasic} }{ {#isBasicBearer} }
127
- // Configure HTTP bearer authorization: { {{name} }}
128
- HttpBearerAuth { {{name} }} = (HttpBearerAuth) defaultClient.getAuthentication("{ {{name} }}");
129
- { {{name} }}.setBearerToken("BEARER TOKEN");{ {/isBasicBearer} }{ {/isBasic} }{ {#isApiKey} }
130
- // Configure API key authorization: { {{name} }}
131
- ApiKeyAuth { {{name} }} = (ApiKeyAuth) defaultClient.getAuthentication("{ {{name} }}");
132
- { {{name} }}.setApiKey("YOUR API KEY");
133
- // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
134
- //{ {{name} }}.setApiKeyPrefix("Token");{ {/isApiKey} }{ {#isOAuth} }
135
- // Configure OAuth2 access token for authorization: { {{name} }}
136
- OAuth { {{name} }} = (OAuth) defaultClient.getAuthentication("{ {{name} }}");
137
- { {{name} }}.setAccessToken("YOUR ACCESS TOKEN");{ {/isOAuth} }{ {#isHttpSignature} }
138
- // Configure HTTP signature authorization: { {{name} }}
139
- HttpSignatureAuth { {{name} }} = (HttpSignatureAuth) defaultClient.getAuthentication("{ {{name} }}");
140
- // All the HTTP signature parameters below should be customized to your environment.
141
- // Configure the keyId
142
- { {{name} }}.setKeyId("YOUR KEY ID");
143
- // Configure the signature algorithm
144
- { {{name} }}.setSigningAlgorithm(SigningAlgorithm.HS2019);
145
- // Configure the specific cryptographic algorithm
146
- { {{name} }}.setAlgorithm(Algorithm.ECDSA_SHA256);
147
- // Configure the cryptographic algorithm parameters, if applicable
148
- { {{name} }}.setAlgorithmParameterSpec(null);
149
- // Set the cryptographic digest algorithm.
150
- { {{name} }}.setDigestAlgorithm("SHA-256");
151
- // Set the HTTP headers that should be included in the HTTP signature.
152
- { {{name} }}.setHeaders(Arrays.asList("date", "host"));
153
- // Set the private key used to sign the HTTP messages
154
- { {{name} }}.setPrivateKey();{ {/isHttpSignature} }
155
- { {/authMethods} }
156
- { {/hasAuthMethods} }
157
-
158
- { {{classname} }} apiInstance = new { {{classname} }}(defaultClient);
159
- { {#allParams} }
160
- { {{dataType} }} { {{paramName} }} = { {{example} }}; // { {{dataType} }} | { {{description} }}
161
- { {/allParams} }
162
- try {
163
- {{#returnType} }{ {{.} }} result = { {/returnType} }apiInstance.{ {{operationId} }}({ {#allParams} }{ {{paramName} }}{ {^-last} }, { {/-last} }{ {/allParams} });{ {#returnType} }
164
- System.out.println(result);{ {/returnType} }
165
- } catch (ApiException e) {
166
- System.err.println(" Exception when calling {{{classname}}}#{{{operationId}}}" );
167
- System.err.println(" Status code: " + e.getCode());
168
- System.err.println(" Reason: " + e.getResponseBody());
169
- System.err.println(" Response headers: " + e.getResponseHeaders());
170
- e.printStackTrace();
171
- }
172
- }
173
- }
174
- { {/-first} }{ {/operation} }{ {/operations} }{ {/-first} }{ {/apis} }{ {/apiInfo} }
175
- ```
176
110
177
111
## Recommendation
178
112
0 commit comments