@leonardo-ai/sdk 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -22
- package/dist/internal/utils/queryparams.js +3 -1
- package/dist/internal/utils/security.js +11 -3
- package/dist/sdk/dataset.js +35 -35
- package/dist/sdk/element.js +7 -7
- package/dist/sdk/generation.js +42 -42
- package/dist/sdk/initimage.js +21 -21
- package/dist/sdk/model.js +42 -42
- package/dist/sdk/sdk.js +4 -4
- package/dist/sdk/user.js +7 -7
- package/dist/sdk/variation.js +28 -28
- package/docs/{models → sdk/models}/operations/createdatasetrequestbody.md +0 -0
- package/docs/sdk/models/operations/createdatasetresponse.md +11 -0
- package/docs/sdk/models/operations/createdatasetresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/creategenerationrequestbody.md +5 -5
- package/docs/sdk/models/operations/creategenerationresponse.md +11 -0
- package/docs/sdk/models/operations/creategenerationresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/createmodelrequestbody.md +3 -3
- package/docs/sdk/models/operations/createmodelresponse.md +11 -0
- package/docs/sdk/models/operations/createmodelresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/createvariationnobgrequestbody.md +0 -0
- package/docs/sdk/models/operations/createvariationnobgresponse.md +11 -0
- package/docs/sdk/models/operations/createvariationnobgresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/createvariationupscalerequestbody.md +0 -0
- package/docs/sdk/models/operations/createvariationupscaleresponse.md +11 -0
- package/docs/sdk/models/operations/createvariationupscaleresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/createvariationupscalesdupscalejoboutput.md +0 -0
- package/docs/{models → sdk/models}/operations/custommodels.md +0 -0
- package/docs/{models → sdk/models}/operations/datasetgenuploadoutput.md +0 -0
- package/docs/{models → sdk/models}/operations/datasetimages.md +0 -0
- package/docs/{models → sdk/models}/operations/datasets.md +0 -0
- package/docs/{models → sdk/models}/operations/datasetuploadoutput.md +0 -0
- package/docs/{models → sdk/models}/operations/deletedatasetbyiddatasets.md +0 -0
- package/docs/{models → sdk/models}/operations/deletedatasetbyidrequest.md +0 -0
- package/docs/sdk/models/operations/deletedatasetbyidresponse.md +11 -0
- package/docs/sdk/models/operations/deletedatasetbyidresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/deletegenerationbyidrequest.md +0 -0
- package/docs/sdk/models/operations/deletegenerationbyidresponse.md +11 -0
- package/docs/sdk/models/operations/deletegenerationbyidresponsebody.md +10 -0
- package/docs/sdk/models/operations/deletegenerationstextureidrequest.md +9 -0
- package/docs/{models → sdk/models}/operations/deletegenerationstextureidrequestbody.md +0 -0
- package/docs/sdk/models/operations/deletegenerationstextureidresponse.md +11 -0
- package/docs/sdk/models/operations/deletegenerationstextureidresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/deleteinitimagebyidrequest.md +0 -0
- package/docs/sdk/models/operations/deleteinitimagebyidresponse.md +11 -0
- package/docs/sdk/models/operations/deleteinitimagebyidresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/deletemodelbyidrequest.md +0 -0
- package/docs/sdk/models/operations/deletemodelbyidresponse.md +11 -0
- package/docs/sdk/models/operations/deletemodelbyidresponsebody.md +10 -0
- package/docs/sdk/models/operations/deletemodels3didrequest.md +9 -0
- package/docs/{models → sdk/models}/operations/deletemodels3didrequestbody.md +0 -0
- package/docs/sdk/models/operations/deletemodels3didresponse.md +11 -0
- package/docs/sdk/models/operations/deletemodels3didresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/elements.md +1 -1
- package/docs/{models → sdk/models}/operations/generatedimages.md +7 -7
- package/docs/sdk/models/operations/generatedimagevariationgeneric.md +14 -0
- package/docs/sdk/models/operations/generationelements.md +12 -0
- package/docs/{models → sdk/models}/operations/generations.md +0 -0
- package/docs/sdk/models/operations/getdatasetbyiddatasets.md +15 -0
- package/docs/{models → sdk/models}/operations/getdatasetbyidrequest.md +0 -0
- package/docs/sdk/models/operations/getdatasetbyidresponse.md +11 -0
- package/docs/sdk/models/operations/getdatasetbyidresponsebody.md +10 -0
- package/docs/sdk/models/operations/getelementsresponse.md +11 -0
- package/docs/sdk/models/operations/getelementsresponsebody.md +10 -0
- package/docs/sdk/models/operations/getgenerationbyidgeneratedimagevariationgeneric.md +13 -0
- package/docs/{models → sdk/models}/operations/getgenerationbyidgenerations.md +6 -6
- package/docs/{models → sdk/models}/operations/getgenerationbyidloras.md +1 -1
- package/docs/{models → sdk/models}/operations/getgenerationbyidrequest.md +0 -0
- package/docs/sdk/models/operations/getgenerationbyidresponse.md +11 -0
- package/docs/sdk/models/operations/getgenerationbyidresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/getgenerationsbyuseridgeneratedimages.md +7 -7
- package/docs/sdk/models/operations/getgenerationsbyuseridgeneratedimagevariationgeneric.md +13 -0
- package/docs/sdk/models/operations/getgenerationsbyuseridgenerationelements.md +12 -0
- package/docs/{models → sdk/models}/operations/getgenerationsbyuseridgenerations.md +6 -6
- package/docs/{models → sdk/models}/operations/getgenerationsbyuseridrequest.md +0 -0
- package/docs/sdk/models/operations/getgenerationsbyuseridresponse.md +11 -0
- package/docs/sdk/models/operations/getgenerationsbyuseridresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/getinitimagebyidinitimages.md +0 -0
- package/docs/{models → sdk/models}/operations/getinitimagebyidrequest.md +0 -0
- package/docs/sdk/models/operations/getinitimagebyidresponse.md +11 -0
- package/docs/sdk/models/operations/getinitimagebyidresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/getmodelbyidcustommodels.md +3 -3
- package/docs/{models → sdk/models}/operations/getmodelbyidrequest.md +0 -0
- package/docs/sdk/models/operations/getmodelbyidresponse.md +11 -0
- package/docs/sdk/models/operations/getmodelbyidresponsebody.md +10 -0
- package/docs/sdk/models/operations/getplatformmodelscustommodels.md +15 -0
- package/docs/{models → sdk/models}/operations/getplatformmodelsgeneratedimages.md +0 -0
- package/docs/{models → sdk/models}/operations/getplatformmodelsrequest.md +0 -0
- package/docs/sdk/models/operations/getplatformmodelsresponse.md +11 -0
- package/docs/sdk/models/operations/getplatformmodelsresponsebody.md +10 -0
- package/docs/sdk/models/operations/getuserselfresponse.md +11 -0
- package/docs/sdk/models/operations/getuserselfresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/getvariationbyidrequest.md +0 -0
- package/docs/sdk/models/operations/getvariationbyidresponse.md +11 -0
- package/docs/sdk/models/operations/getvariationbyidresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/initimages.md +0 -0
- package/docs/{models → sdk/models}/operations/initimageuploadoutput.md +0 -0
- package/docs/{models → sdk/models}/operations/loras.md +1 -1
- package/docs/{models → sdk/models}/operations/modelassets.md +0 -0
- package/docs/{models → sdk/models}/operations/modelassettexturegenerations.md +0 -0
- package/docs/{models → sdk/models}/operations/modelassetuploadoutput.md +0 -0
- package/docs/{models → sdk/models}/operations/postgenerationstexturerequestbody.md +0 -0
- package/docs/sdk/models/operations/postgenerationstextureresponse.md +11 -0
- package/docs/sdk/models/operations/postgenerationstextureresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/postmodels3duploadrequestbody.md +0 -0
- package/docs/sdk/models/operations/postmodels3duploadresponse.md +11 -0
- package/docs/sdk/models/operations/postmodels3duploadresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/postvariationsunzoomrequestbody.md +0 -0
- package/docs/sdk/models/operations/postvariationsunzoomresponse.md +11 -0
- package/docs/sdk/models/operations/postvariationsunzoomresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/sdgenerationoutput.md +0 -0
- package/docs/{models → sdk/models}/operations/sdtrainingoutput.md +0 -0
- package/docs/{models → sdk/models}/operations/sdunzoomoutput.md +0 -0
- package/docs/{models → sdk/models}/operations/sdupscalejoboutput.md +0 -0
- package/docs/{models → sdk/models}/operations/texturegenerationjoboutput.md +0 -0
- package/docs/sdk/models/operations/uploaddatasetimagefromgenrequest.md +9 -0
- package/docs/{models → sdk/models}/operations/uploaddatasetimagefromgenrequestbody.md +0 -0
- package/docs/sdk/models/operations/uploaddatasetimagefromgenresponse.md +11 -0
- package/docs/sdk/models/operations/uploaddatasetimagefromgenresponsebody.md +10 -0
- package/docs/sdk/models/operations/uploaddatasetimagerequest.md +9 -0
- package/docs/{models → sdk/models}/operations/uploaddatasetimagerequestbody.md +0 -0
- package/docs/sdk/models/operations/uploaddatasetimageresponse.md +11 -0
- package/docs/sdk/models/operations/uploaddatasetimageresponsebody.md +10 -0
- package/docs/{models → sdk/models}/operations/uploadinitimagerequestbody.md +0 -0
- package/docs/sdk/models/operations/uploadinitimageresponse.md +11 -0
- package/docs/sdk/models/operations/uploadinitimageresponsebody.md +10 -0
- package/docs/sdk/models/operations/userdetails.md +15 -0
- package/docs/{models → sdk/models}/operations/users.md +0 -0
- package/docs/{models → sdk/models}/shared/controlnettype.md +0 -0
- package/docs/{models → sdk/models}/shared/custommodeltype.md +0 -0
- package/docs/{models → sdk/models}/shared/elementinput.md +0 -0
- package/docs/{models → sdk/models}/shared/jobstatus.md +0 -0
- package/docs/{models → sdk/models}/shared/sdgenerationschedulers.md +0 -0
- package/docs/{models → sdk/models}/shared/sdgenerationstyle.md +0 -0
- package/docs/{models → sdk/models}/shared/sdversions.md +0 -0
- package/docs/{models → sdk/models}/shared/security.md +0 -0
- package/docs/{models → sdk/models}/shared/strength.md +0 -0
- package/docs/{models → sdk/models}/shared/variationtype.md +0 -0
- package/docs/sdks/dataset/README.md +40 -25
- package/docs/sdks/element/README.md +6 -3
- package/docs/sdks/generation/README.md +44 -26
- package/docs/sdks/initimage/README.md +20 -11
- package/docs/sdks/leonardo/README.md +0 -0
- package/docs/sdks/model/README.md +44 -26
- package/docs/sdks/user/README.md +6 -3
- package/docs/sdks/variation/README.md +33 -21
- package/package.json +1 -1
- package/docs/models/operations/createdatasetresponse.md +0 -11
- package/docs/models/operations/createdatasetresponsebody.md +0 -10
- package/docs/models/operations/creategenerationresponse.md +0 -11
- package/docs/models/operations/creategenerationresponsebody.md +0 -10
- package/docs/models/operations/createmodelresponse.md +0 -11
- package/docs/models/operations/createmodelresponsebody.md +0 -10
- package/docs/models/operations/createvariationnobgresponse.md +0 -11
- package/docs/models/operations/createvariationnobgresponsebody.md +0 -10
- package/docs/models/operations/createvariationupscaleresponse.md +0 -11
- package/docs/models/operations/createvariationupscaleresponsebody.md +0 -10
- package/docs/models/operations/deletedatasetbyidresponse.md +0 -11
- package/docs/models/operations/deletedatasetbyidresponsebody.md +0 -10
- package/docs/models/operations/deletegenerationbyidresponse.md +0 -11
- package/docs/models/operations/deletegenerationbyidresponsebody.md +0 -10
- package/docs/models/operations/deletegenerationstextureidrequest.md +0 -9
- package/docs/models/operations/deletegenerationstextureidresponse.md +0 -11
- package/docs/models/operations/deletegenerationstextureidresponsebody.md +0 -10
- package/docs/models/operations/deleteinitimagebyidresponse.md +0 -11
- package/docs/models/operations/deleteinitimagebyidresponsebody.md +0 -10
- package/docs/models/operations/deletemodelbyidresponse.md +0 -11
- package/docs/models/operations/deletemodelbyidresponsebody.md +0 -10
- package/docs/models/operations/deletemodels3didrequest.md +0 -9
- package/docs/models/operations/deletemodels3didresponse.md +0 -11
- package/docs/models/operations/deletemodels3didresponsebody.md +0 -10
- package/docs/models/operations/generatedimagevariationgeneric.md +0 -14
- package/docs/models/operations/generationelements.md +0 -12
- package/docs/models/operations/getdatasetbyiddatasets.md +0 -15
- package/docs/models/operations/getdatasetbyidresponse.md +0 -11
- package/docs/models/operations/getdatasetbyidresponsebody.md +0 -10
- package/docs/models/operations/getelementsresponse.md +0 -11
- package/docs/models/operations/getelementsresponsebody.md +0 -10
- package/docs/models/operations/getgenerationbyidgeneratedimagevariationgeneric.md +0 -13
- package/docs/models/operations/getgenerationbyidresponse.md +0 -11
- package/docs/models/operations/getgenerationbyidresponsebody.md +0 -10
- package/docs/models/operations/getgenerationsbyuseridgeneratedimagevariationgeneric.md +0 -13
- package/docs/models/operations/getgenerationsbyuseridgenerationelements.md +0 -12
- package/docs/models/operations/getgenerationsbyuseridresponse.md +0 -11
- package/docs/models/operations/getgenerationsbyuseridresponsebody.md +0 -10
- package/docs/models/operations/getinitimagebyidresponse.md +0 -11
- package/docs/models/operations/getinitimagebyidresponsebody.md +0 -10
- package/docs/models/operations/getmodelbyidresponse.md +0 -11
- package/docs/models/operations/getmodelbyidresponsebody.md +0 -10
- package/docs/models/operations/getplatformmodelscustommodels.md +0 -15
- package/docs/models/operations/getplatformmodelsresponse.md +0 -11
- package/docs/models/operations/getplatformmodelsresponsebody.md +0 -10
- package/docs/models/operations/getuserselfresponse.md +0 -11
- package/docs/models/operations/getuserselfresponsebody.md +0 -10
- package/docs/models/operations/getvariationbyidresponse.md +0 -11
- package/docs/models/operations/getvariationbyidresponsebody.md +0 -10
- package/docs/models/operations/postgenerationstextureresponse.md +0 -11
- package/docs/models/operations/postgenerationstextureresponsebody.md +0 -10
- package/docs/models/operations/postmodels3duploadresponse.md +0 -11
- package/docs/models/operations/postmodels3duploadresponsebody.md +0 -10
- package/docs/models/operations/postvariationsunzoomresponse.md +0 -11
- package/docs/models/operations/postvariationsunzoomresponsebody.md +0 -10
- package/docs/models/operations/uploaddatasetimagefromgenrequest.md +0 -9
- package/docs/models/operations/uploaddatasetimagefromgenresponse.md +0 -11
- package/docs/models/operations/uploaddatasetimagefromgenresponsebody.md +0 -10
- package/docs/models/operations/uploaddatasetimagerequest.md +0 -9
- package/docs/models/operations/uploaddatasetimageresponse.md +0 -11
- package/docs/models/operations/uploaddatasetimageresponsebody.md +0 -10
- package/docs/models/operations/uploadinitimageresponse.md +0 -11
- package/docs/models/operations/uploadinitimageresponsebody.md +0 -10
- package/docs/models/operations/userdetails.md +0 -15
package/README.md
CHANGED
|
@@ -30,6 +30,8 @@ To get access to the API and fetch an API key, please sign up for [access](https
|
|
|
30
30
|
|
|
31
31
|
## SDK Example Usage
|
|
32
32
|
<!-- Start SDK Example Usage -->
|
|
33
|
+
### Example
|
|
34
|
+
|
|
33
35
|
```typescript
|
|
34
36
|
import { Leonardo } from "@leonardo-ai/sdk";
|
|
35
37
|
|
|
@@ -54,7 +56,7 @@ import { Leonardo } from "@leonardo-ai/sdk";
|
|
|
54
56
|
## Available Resources and Operations
|
|
55
57
|
|
|
56
58
|
|
|
57
|
-
### [
|
|
59
|
+
### [dataset](docs/sdks/dataset/README.md)
|
|
58
60
|
|
|
59
61
|
* [createDataset](docs/sdks/dataset/README.md#createdataset) - Create a Dataset
|
|
60
62
|
* [deleteDatasetById](docs/sdks/dataset/README.md#deletedatasetbyid) - Delete a Single Dataset by ID
|
|
@@ -62,11 +64,11 @@ import { Leonardo } from "@leonardo-ai/sdk";
|
|
|
62
64
|
* [uploadDatasetImage](docs/sdks/dataset/README.md#uploaddatasetimage) - Upload dataset image
|
|
63
65
|
* [uploadDatasetImageFromGen](docs/sdks/dataset/README.md#uploaddatasetimagefromgen) - Upload a Single Generated Image to a Dataset
|
|
64
66
|
|
|
65
|
-
### [
|
|
67
|
+
### [element](docs/sdks/element/README.md)
|
|
66
68
|
|
|
67
69
|
* [getElements](docs/sdks/element/README.md#getelements) - List Elements
|
|
68
70
|
|
|
69
|
-
### [
|
|
71
|
+
### [generation](docs/sdks/generation/README.md)
|
|
70
72
|
|
|
71
73
|
* [createGeneration](docs/sdks/generation/README.md#creategeneration) - Create a Generation of Images
|
|
72
74
|
* [deleteGenerationById](docs/sdks/generation/README.md#deletegenerationbyid) - Delete a Single Generation
|
|
@@ -75,17 +77,17 @@ import { Leonardo } from "@leonardo-ai/sdk";
|
|
|
75
77
|
* [getGenerationsByUserId](docs/sdks/generation/README.md#getgenerationsbyuserid) - Get generations by user ID
|
|
76
78
|
* [postGenerationsTexture](docs/sdks/generation/README.md#postgenerationstexture) - Create Texture Generation
|
|
77
79
|
|
|
78
|
-
### [
|
|
80
|
+
### [initImage](docs/sdks/initimage/README.md)
|
|
79
81
|
|
|
80
82
|
* [deleteInitImageById](docs/sdks/initimage/README.md#deleteinitimagebyid) - Delete init image
|
|
81
83
|
* [getInitImageById](docs/sdks/initimage/README.md#getinitimagebyid) - Get single init image
|
|
82
84
|
* [uploadInitImage](docs/sdks/initimage/README.md#uploadinitimage) - Upload init image
|
|
83
85
|
|
|
84
|
-
### [
|
|
86
|
+
### [user](docs/sdks/user/README.md)
|
|
85
87
|
|
|
86
88
|
* [getUserSelf](docs/sdks/user/README.md#getuserself) - Get user information
|
|
87
89
|
|
|
88
|
-
### [
|
|
90
|
+
### [model](docs/sdks/model/README.md)
|
|
89
91
|
|
|
90
92
|
* [createModel](docs/sdks/model/README.md#createmodel) - Train a Custom Model
|
|
91
93
|
* [deleteModelById](docs/sdks/model/README.md#deletemodelbyid) - Delete a Single Custom Model by ID
|
|
@@ -94,7 +96,7 @@ import { Leonardo } from "@leonardo-ai/sdk";
|
|
|
94
96
|
* [getPlatformModels](docs/sdks/model/README.md#getplatformmodels) - List Platform Models
|
|
95
97
|
* [postModels3dUpload](docs/sdks/model/README.md#postmodels3dupload) - Upload 3D Model
|
|
96
98
|
|
|
97
|
-
### [
|
|
99
|
+
### [variation](docs/sdks/variation/README.md)
|
|
98
100
|
|
|
99
101
|
* [createVariationNoBG](docs/sdks/variation/README.md#createvariationnobg) - Create no background
|
|
100
102
|
* [createVariationUpscale](docs/sdks/variation/README.md#createvariationupscale) - Create upscale
|
|
@@ -131,19 +133,46 @@ Here's an example of one such pagination call:
|
|
|
131
133
|
|
|
132
134
|
|
|
133
135
|
<!-- Start Error Handling -->
|
|
134
|
-
|
|
136
|
+
## Error Handling
|
|
137
|
+
|
|
138
|
+
Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an error. If Error objects are specified in your OpenAPI Spec, the SDK will throw the appropriate Error type.
|
|
139
|
+
|
|
140
|
+
| Error Object | Status Code | Content Type |
|
|
141
|
+
| --------------- | --------------- | --------------- |
|
|
142
|
+
| errors.SDKError | 400-600 | */* |
|
|
143
|
+
|
|
144
|
+
Example
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { Leonardo } from "@leonardo-ai/sdk";
|
|
148
|
+
|
|
149
|
+
(async () => {
|
|
150
|
+
const sdk = new Leonardo({
|
|
151
|
+
bearerAuth: "",
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
let res;
|
|
155
|
+
try {
|
|
156
|
+
res = await sdk.dataset.createDataset({
|
|
157
|
+
name: "string",
|
|
158
|
+
});
|
|
159
|
+
} catch (e) {}
|
|
135
160
|
|
|
136
|
-
|
|
161
|
+
if (res.statusCode == 200) {
|
|
162
|
+
// handle response
|
|
163
|
+
}
|
|
164
|
+
})();
|
|
165
|
+
|
|
166
|
+
```
|
|
137
167
|
<!-- End Error Handling -->
|
|
138
168
|
|
|
139
169
|
|
|
140
170
|
|
|
141
171
|
<!-- Start Custom HTTP Client -->
|
|
142
|
-
|
|
172
|
+
## Custom HTTP Client
|
|
143
173
|
|
|
144
174
|
The Typescript SDK makes API calls using the (axios)[https://axios-http.com/docs/intro] HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `AxiosInstance` object.
|
|
145
175
|
|
|
146
|
-
|
|
147
176
|
For example, you could specify a header for every request that your sdk makes as follows:
|
|
148
177
|
|
|
149
178
|
```typescript
|
|
@@ -154,7 +183,6 @@ const httpClient = axios.create({
|
|
|
154
183
|
headers: {'x-custom-header': 'someValue'}
|
|
155
184
|
})
|
|
156
185
|
|
|
157
|
-
|
|
158
186
|
const sdk = new Leonardo({defaultClient: httpClient});
|
|
159
187
|
```
|
|
160
188
|
<!-- End Custom HTTP Client -->
|
|
@@ -162,9 +190,9 @@ const sdk = new Leonardo({defaultClient: httpClient});
|
|
|
162
190
|
|
|
163
191
|
|
|
164
192
|
<!-- Start Server Selection -->
|
|
165
|
-
|
|
193
|
+
## Server Selection
|
|
166
194
|
|
|
167
|
-
|
|
195
|
+
### Select Server by Index
|
|
168
196
|
|
|
169
197
|
You can override the default server globally by passing a server index to the `serverIdx: number` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
|
|
170
198
|
|
|
@@ -172,7 +200,7 @@ You can override the default server globally by passing a server index to the `s
|
|
|
172
200
|
| - | ------ | --------- |
|
|
173
201
|
| 0 | `https://cloud.leonardo.ai/api/rest/v1` | None |
|
|
174
202
|
|
|
175
|
-
|
|
203
|
+
#### Example
|
|
176
204
|
|
|
177
205
|
```typescript
|
|
178
206
|
import { Leonardo } from "@leonardo-ai/sdk";
|
|
@@ -195,10 +223,9 @@ import { Leonardo } from "@leonardo-ai/sdk";
|
|
|
195
223
|
```
|
|
196
224
|
|
|
197
225
|
|
|
198
|
-
|
|
226
|
+
### Override Server URL Per-Client
|
|
199
227
|
|
|
200
228
|
The default server can also be overridden globally by passing a URL to the `serverURL: str` optional parameter when initializing the SDK client instance. For example:
|
|
201
|
-
|
|
202
229
|
```typescript
|
|
203
230
|
import { Leonardo } from "@leonardo-ai/sdk";
|
|
204
231
|
|
|
@@ -223,19 +250,17 @@ import { Leonardo } from "@leonardo-ai/sdk";
|
|
|
223
250
|
|
|
224
251
|
|
|
225
252
|
<!-- Start Authentication -->
|
|
253
|
+
## Authentication
|
|
226
254
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
## Per-Client Security Schemes
|
|
255
|
+
### Per-Client Security Schemes
|
|
230
256
|
|
|
231
|
-
|
|
257
|
+
This SDK supports the following security scheme globally:
|
|
232
258
|
|
|
233
259
|
| Name | Type | Scheme |
|
|
234
260
|
| ------------ | ------------ | ------------ |
|
|
235
261
|
| `bearerAuth` | http | HTTP Bearer |
|
|
236
262
|
|
|
237
263
|
To authenticate with the API the `bearerAuth` parameter must be set when initializing the SDK client instance. For example:
|
|
238
|
-
|
|
239
264
|
```typescript
|
|
240
265
|
import { Leonardo } from "@leonardo-ai/sdk";
|
|
241
266
|
|
|
@@ -24,7 +24,9 @@ var utils_1 = require("./utils");
|
|
|
24
24
|
var requestbody_1 = require("./requestbody");
|
|
25
25
|
exports.qpMetadataKey = "queryParam";
|
|
26
26
|
var queryStringPrefix = "?";
|
|
27
|
-
var filterAndJoin = function (strings) {
|
|
27
|
+
var filterAndJoin = function (strings) {
|
|
28
|
+
return strings.filter(function (s) { return !!s; }).join("&");
|
|
29
|
+
};
|
|
28
30
|
function serializeQueryParams(queryParams, globals) {
|
|
29
31
|
var queryStringParts = [];
|
|
30
32
|
if (!queryParams)
|
|
@@ -138,14 +138,22 @@ function parseSecuritySchemeValue(properties, schemeDecorator, securityDecorator
|
|
|
138
138
|
properties.headers[securityDecorator.Name] = value;
|
|
139
139
|
break;
|
|
140
140
|
case "oauth2":
|
|
141
|
-
properties.headers[securityDecorator.Name] = value
|
|
141
|
+
properties.headers[securityDecorator.Name] = value
|
|
142
|
+
.toLowerCase()
|
|
143
|
+
.startsWith("bearer ")
|
|
144
|
+
? value
|
|
145
|
+
: "Bearer ".concat(value);
|
|
142
146
|
break;
|
|
143
147
|
case "http":
|
|
144
148
|
switch (schemeDecorator.SubType) {
|
|
145
149
|
case "basic":
|
|
146
150
|
break;
|
|
147
151
|
case "bearer":
|
|
148
|
-
properties.headers[securityDecorator.Name] = value
|
|
152
|
+
properties.headers[securityDecorator.Name] = value
|
|
153
|
+
.toLowerCase()
|
|
154
|
+
.startsWith("bearer ")
|
|
155
|
+
? value
|
|
156
|
+
: "Bearer ".concat(value);
|
|
149
157
|
break;
|
|
150
158
|
default:
|
|
151
159
|
throw new Error("not supported");
|
|
@@ -174,7 +182,7 @@ function parseBasicAuthScheme(properties, scheme) {
|
|
|
174
182
|
break;
|
|
175
183
|
}
|
|
176
184
|
});
|
|
177
|
-
properties.headers["Authorization"] = "Basic ".concat(Buffer.from("".concat(username, ":").concat(password)).toString(
|
|
185
|
+
properties.headers["Authorization"] = "Basic ".concat(Buffer.from("".concat(username, ":").concat(password)).toString("base64"));
|
|
178
186
|
}
|
|
179
187
|
var SecurityDecorator = /** @class */ (function () {
|
|
180
188
|
function SecurityDecorator(Name, Type, Option, Scheme, SubType) {
|
package/dist/sdk/dataset.js
CHANGED
|
@@ -107,7 +107,7 @@ var Dataset = /** @class */ (function () {
|
|
|
107
107
|
Dataset.prototype.createDataset = function (req, config) {
|
|
108
108
|
var _a, _b;
|
|
109
109
|
return __awaiter(this, void 0, void 0, function () {
|
|
110
|
-
var baseURL,
|
|
110
|
+
var baseURL, operationUrl, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes;
|
|
111
111
|
var _d;
|
|
112
112
|
return __generator(this, function (_e) {
|
|
113
113
|
switch (_e.label) {
|
|
@@ -116,7 +116,7 @@ var Dataset = /** @class */ (function () {
|
|
|
116
116
|
req = new operations.CreateDatasetRequestBody(req);
|
|
117
117
|
}
|
|
118
118
|
baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
|
|
119
|
-
|
|
119
|
+
operationUrl = baseURL.replace(/\/$/, "") + "/datasets";
|
|
120
120
|
_c = __read([{}, null], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
|
|
121
121
|
try {
|
|
122
122
|
_d = __read(utils.serializeRequestBody(req, "request", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
|
|
@@ -143,26 +143,26 @@ var Dataset = /** @class */ (function () {
|
|
|
143
143
|
throw new Error("request body is required");
|
|
144
144
|
headers["Accept"] = "application/json";
|
|
145
145
|
headers["user-agent"] = this.sdkConfiguration.userAgent;
|
|
146
|
-
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url:
|
|
146
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
|
|
147
147
|
case 3:
|
|
148
148
|
httpRes = _e.sent();
|
|
149
|
-
|
|
149
|
+
responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
|
|
150
150
|
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
151
151
|
throw new Error("status code not found in response: ".concat(httpRes));
|
|
152
152
|
}
|
|
153
153
|
res = new operations.CreateDatasetResponse({
|
|
154
154
|
statusCode: httpRes.status,
|
|
155
|
-
contentType:
|
|
155
|
+
contentType: responseContentType,
|
|
156
156
|
rawResponse: httpRes,
|
|
157
157
|
});
|
|
158
158
|
decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
|
|
159
159
|
switch (true) {
|
|
160
160
|
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
161
|
-
if (utils.matchContentType(
|
|
161
|
+
if (utils.matchContentType(responseContentType, "application/json")) {
|
|
162
162
|
res.object = utils.objectToClass(JSON.parse(decodedRes), operations.CreateDatasetResponseBody);
|
|
163
163
|
}
|
|
164
164
|
else {
|
|
165
|
-
throw new errors.SDKError("unknown content-type received: " +
|
|
165
|
+
throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
|
|
166
166
|
}
|
|
167
167
|
break;
|
|
168
168
|
}
|
|
@@ -180,7 +180,7 @@ var Dataset = /** @class */ (function () {
|
|
|
180
180
|
Dataset.prototype.deleteDatasetById = function (id, config) {
|
|
181
181
|
var _a, _b;
|
|
182
182
|
return __awaiter(this, void 0, void 0, function () {
|
|
183
|
-
var req, baseURL,
|
|
183
|
+
var req, baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes;
|
|
184
184
|
return __generator(this, function (_c) {
|
|
185
185
|
switch (_c.label) {
|
|
186
186
|
case 0:
|
|
@@ -188,7 +188,7 @@ var Dataset = /** @class */ (function () {
|
|
|
188
188
|
id: id,
|
|
189
189
|
});
|
|
190
190
|
baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
|
|
191
|
-
|
|
191
|
+
operationUrl = utils.generateURL(baseURL, "/datasets/{id}", req);
|
|
192
192
|
client = this.sdkConfiguration.defaultClient;
|
|
193
193
|
globalSecurity = this.sdkConfiguration.security;
|
|
194
194
|
if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
|
|
@@ -204,26 +204,26 @@ var Dataset = /** @class */ (function () {
|
|
|
204
204
|
headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
|
|
205
205
|
headers["Accept"] = "application/json";
|
|
206
206
|
headers["user-agent"] = this.sdkConfiguration.userAgent;
|
|
207
|
-
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url:
|
|
207
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "delete", headers: headers, responseType: "arraybuffer" }, config))];
|
|
208
208
|
case 3:
|
|
209
209
|
httpRes = _c.sent();
|
|
210
|
-
|
|
210
|
+
responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
|
|
211
211
|
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
212
212
|
throw new Error("status code not found in response: ".concat(httpRes));
|
|
213
213
|
}
|
|
214
214
|
res = new operations.DeleteDatasetByIdResponse({
|
|
215
215
|
statusCode: httpRes.status,
|
|
216
|
-
contentType:
|
|
216
|
+
contentType: responseContentType,
|
|
217
217
|
rawResponse: httpRes,
|
|
218
218
|
});
|
|
219
219
|
decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
|
|
220
220
|
switch (true) {
|
|
221
221
|
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
222
|
-
if (utils.matchContentType(
|
|
222
|
+
if (utils.matchContentType(responseContentType, "application/json")) {
|
|
223
223
|
res.object = utils.objectToClass(JSON.parse(decodedRes), operations.DeleteDatasetByIdResponseBody);
|
|
224
224
|
}
|
|
225
225
|
else {
|
|
226
|
-
throw new errors.SDKError("unknown content-type received: " +
|
|
226
|
+
throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
|
|
227
227
|
}
|
|
228
228
|
break;
|
|
229
229
|
}
|
|
@@ -241,7 +241,7 @@ var Dataset = /** @class */ (function () {
|
|
|
241
241
|
Dataset.prototype.getDatasetById = function (id, config) {
|
|
242
242
|
var _a, _b;
|
|
243
243
|
return __awaiter(this, void 0, void 0, function () {
|
|
244
|
-
var req, baseURL,
|
|
244
|
+
var req, baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes;
|
|
245
245
|
return __generator(this, function (_c) {
|
|
246
246
|
switch (_c.label) {
|
|
247
247
|
case 0:
|
|
@@ -249,7 +249,7 @@ var Dataset = /** @class */ (function () {
|
|
|
249
249
|
id: id,
|
|
250
250
|
});
|
|
251
251
|
baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
|
|
252
|
-
|
|
252
|
+
operationUrl = utils.generateURL(baseURL, "/datasets/{id}", req);
|
|
253
253
|
client = this.sdkConfiguration.defaultClient;
|
|
254
254
|
globalSecurity = this.sdkConfiguration.security;
|
|
255
255
|
if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
|
|
@@ -265,26 +265,26 @@ var Dataset = /** @class */ (function () {
|
|
|
265
265
|
headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
|
|
266
266
|
headers["Accept"] = "application/json";
|
|
267
267
|
headers["user-agent"] = this.sdkConfiguration.userAgent;
|
|
268
|
-
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url:
|
|
268
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
|
|
269
269
|
case 3:
|
|
270
270
|
httpRes = _c.sent();
|
|
271
|
-
|
|
271
|
+
responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
|
|
272
272
|
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
273
273
|
throw new Error("status code not found in response: ".concat(httpRes));
|
|
274
274
|
}
|
|
275
275
|
res = new operations.GetDatasetByIdResponse({
|
|
276
276
|
statusCode: httpRes.status,
|
|
277
|
-
contentType:
|
|
277
|
+
contentType: responseContentType,
|
|
278
278
|
rawResponse: httpRes,
|
|
279
279
|
});
|
|
280
280
|
decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
|
|
281
281
|
switch (true) {
|
|
282
282
|
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
283
|
-
if (utils.matchContentType(
|
|
283
|
+
if (utils.matchContentType(responseContentType, "application/json")) {
|
|
284
284
|
res.object = utils.objectToClass(JSON.parse(decodedRes), operations.GetDatasetByIdResponseBody);
|
|
285
285
|
}
|
|
286
286
|
else {
|
|
287
|
-
throw new errors.SDKError("unknown content-type received: " +
|
|
287
|
+
throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
|
|
288
288
|
}
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
@@ -302,7 +302,7 @@ var Dataset = /** @class */ (function () {
|
|
|
302
302
|
Dataset.prototype.uploadDatasetImage = function (requestBody, datasetId, config) {
|
|
303
303
|
var _a, _b;
|
|
304
304
|
return __awaiter(this, void 0, void 0, function () {
|
|
305
|
-
var req, baseURL,
|
|
305
|
+
var req, baseURL, operationUrl, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes;
|
|
306
306
|
var _d;
|
|
307
307
|
return __generator(this, function (_e) {
|
|
308
308
|
switch (_e.label) {
|
|
@@ -312,7 +312,7 @@ var Dataset = /** @class */ (function () {
|
|
|
312
312
|
datasetId: datasetId,
|
|
313
313
|
});
|
|
314
314
|
baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
|
|
315
|
-
|
|
315
|
+
operationUrl = utils.generateURL(baseURL, "/datasets/{datasetId}/upload", req);
|
|
316
316
|
_c = __read([{}, null], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
|
|
317
317
|
try {
|
|
318
318
|
_d = __read(utils.serializeRequestBody(req, "requestBody", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
|
|
@@ -339,26 +339,26 @@ var Dataset = /** @class */ (function () {
|
|
|
339
339
|
throw new Error("request body is required");
|
|
340
340
|
headers["Accept"] = "application/json";
|
|
341
341
|
headers["user-agent"] = this.sdkConfiguration.userAgent;
|
|
342
|
-
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url:
|
|
342
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
|
|
343
343
|
case 3:
|
|
344
344
|
httpRes = _e.sent();
|
|
345
|
-
|
|
345
|
+
responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
|
|
346
346
|
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
347
347
|
throw new Error("status code not found in response: ".concat(httpRes));
|
|
348
348
|
}
|
|
349
349
|
res = new operations.UploadDatasetImageResponse({
|
|
350
350
|
statusCode: httpRes.status,
|
|
351
|
-
contentType:
|
|
351
|
+
contentType: responseContentType,
|
|
352
352
|
rawResponse: httpRes,
|
|
353
353
|
});
|
|
354
354
|
decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
|
|
355
355
|
switch (true) {
|
|
356
356
|
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
357
|
-
if (utils.matchContentType(
|
|
357
|
+
if (utils.matchContentType(responseContentType, "application/json")) {
|
|
358
358
|
res.object = utils.objectToClass(JSON.parse(decodedRes), operations.UploadDatasetImageResponseBody);
|
|
359
359
|
}
|
|
360
360
|
else {
|
|
361
|
-
throw new errors.SDKError("unknown content-type received: " +
|
|
361
|
+
throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
|
|
362
362
|
}
|
|
363
363
|
break;
|
|
364
364
|
}
|
|
@@ -376,7 +376,7 @@ var Dataset = /** @class */ (function () {
|
|
|
376
376
|
Dataset.prototype.uploadDatasetImageFromGen = function (requestBody, datasetId, config) {
|
|
377
377
|
var _a, _b;
|
|
378
378
|
return __awaiter(this, void 0, void 0, function () {
|
|
379
|
-
var req, baseURL,
|
|
379
|
+
var req, baseURL, operationUrl, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes;
|
|
380
380
|
var _d;
|
|
381
381
|
return __generator(this, function (_e) {
|
|
382
382
|
switch (_e.label) {
|
|
@@ -386,7 +386,7 @@ var Dataset = /** @class */ (function () {
|
|
|
386
386
|
datasetId: datasetId,
|
|
387
387
|
});
|
|
388
388
|
baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
|
|
389
|
-
|
|
389
|
+
operationUrl = utils.generateURL(baseURL, "/datasets/{datasetId}/upload/gen", req);
|
|
390
390
|
_c = __read([{}, null], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
|
|
391
391
|
try {
|
|
392
392
|
_d = __read(utils.serializeRequestBody(req, "requestBody", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
|
|
@@ -413,26 +413,26 @@ var Dataset = /** @class */ (function () {
|
|
|
413
413
|
throw new Error("request body is required");
|
|
414
414
|
headers["Accept"] = "application/json";
|
|
415
415
|
headers["user-agent"] = this.sdkConfiguration.userAgent;
|
|
416
|
-
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url:
|
|
416
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
|
|
417
417
|
case 3:
|
|
418
418
|
httpRes = _e.sent();
|
|
419
|
-
|
|
419
|
+
responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
|
|
420
420
|
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
421
421
|
throw new Error("status code not found in response: ".concat(httpRes));
|
|
422
422
|
}
|
|
423
423
|
res = new operations.UploadDatasetImageFromGenResponse({
|
|
424
424
|
statusCode: httpRes.status,
|
|
425
|
-
contentType:
|
|
425
|
+
contentType: responseContentType,
|
|
426
426
|
rawResponse: httpRes,
|
|
427
427
|
});
|
|
428
428
|
decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
|
|
429
429
|
switch (true) {
|
|
430
430
|
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
431
|
-
if (utils.matchContentType(
|
|
431
|
+
if (utils.matchContentType(responseContentType, "application/json")) {
|
|
432
432
|
res.object = utils.objectToClass(JSON.parse(decodedRes), operations.UploadDatasetImageFromGenResponseBody);
|
|
433
433
|
}
|
|
434
434
|
else {
|
|
435
|
-
throw new errors.SDKError("unknown content-type received: " +
|
|
435
|
+
throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
|
|
436
436
|
}
|
|
437
437
|
break;
|
|
438
438
|
}
|
package/dist/sdk/element.js
CHANGED
|
@@ -91,12 +91,12 @@ var Element = /** @class */ (function () {
|
|
|
91
91
|
Element.prototype.getElements = function (config) {
|
|
92
92
|
var _a, _b;
|
|
93
93
|
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
-
var baseURL,
|
|
94
|
+
var baseURL, operationUrl, client, globalSecurity, properties, headers, httpRes, responseContentType, res, decodedRes;
|
|
95
95
|
return __generator(this, function (_c) {
|
|
96
96
|
switch (_c.label) {
|
|
97
97
|
case 0:
|
|
98
98
|
baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
|
|
99
|
-
|
|
99
|
+
operationUrl = baseURL.replace(/\/$/, "") + "/elements";
|
|
100
100
|
client = this.sdkConfiguration.defaultClient;
|
|
101
101
|
globalSecurity = this.sdkConfiguration.security;
|
|
102
102
|
if (!(typeof globalSecurity === "function")) return [3 /*break*/, 2];
|
|
@@ -112,26 +112,26 @@ var Element = /** @class */ (function () {
|
|
|
112
112
|
headers = __assign(__assign({}, config === null || config === void 0 ? void 0 : config.headers), properties.headers);
|
|
113
113
|
headers["Accept"] = "application/json";
|
|
114
114
|
headers["user-agent"] = this.sdkConfiguration.userAgent;
|
|
115
|
-
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url:
|
|
115
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: operationUrl, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
|
|
116
116
|
case 3:
|
|
117
117
|
httpRes = _c.sent();
|
|
118
|
-
|
|
118
|
+
responseContentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
|
|
119
119
|
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
120
120
|
throw new Error("status code not found in response: ".concat(httpRes));
|
|
121
121
|
}
|
|
122
122
|
res = new operations.GetElementsResponse({
|
|
123
123
|
statusCode: httpRes.status,
|
|
124
|
-
contentType:
|
|
124
|
+
contentType: responseContentType,
|
|
125
125
|
rawResponse: httpRes,
|
|
126
126
|
});
|
|
127
127
|
decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
|
|
128
128
|
switch (true) {
|
|
129
129
|
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
130
|
-
if (utils.matchContentType(
|
|
130
|
+
if (utils.matchContentType(responseContentType, "application/json")) {
|
|
131
131
|
res.object = utils.objectToClass(JSON.parse(decodedRes), operations.GetElementsResponseBody);
|
|
132
132
|
}
|
|
133
133
|
else {
|
|
134
|
-
throw new errors.SDKError("unknown content-type received: " +
|
|
134
|
+
throw new errors.SDKError("unknown content-type received: " + responseContentType, httpRes.status, decodedRes, httpRes);
|
|
135
135
|
}
|
|
136
136
|
break;
|
|
137
137
|
}
|