@leonardo-ai/sdk 1.20.3 → 1.25.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 +31 -35
- package/dist/sdk/dataset.js +241 -161
- package/dist/sdk/generation.js +184 -112
- package/dist/sdk/initimage.js +148 -86
- package/dist/sdk/model.js +148 -85
- package/dist/sdk/sdk.js +2 -2
- package/dist/sdk/user.js +66 -21
- package/dist/sdk/variation.js +114 -60
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -30,26 +30,22 @@ To get access to the API and fetch an API key, please sign up for [access](https
|
|
|
30
30
|
## SDK Example Usage
|
|
31
31
|
<!-- Start SDK Example Usage -->
|
|
32
32
|
```typescript
|
|
33
|
-
import {
|
|
34
|
-
CreateDatasetRequestBody,
|
|
35
|
-
CreateDatasetResponse
|
|
36
|
-
} from "@leonardo-ai/sdk/dist/sdk/models/operations";
|
|
37
|
-
|
|
38
|
-
import { AxiosError } from "axios";
|
|
39
33
|
import { Leonardo } from "@leonardo-ai/sdk";
|
|
34
|
+
import { CreateDatasetResponse } from "@leonardo-ai/sdk/dist/sdk/models/operations";
|
|
35
|
+
|
|
40
36
|
const sdk = new Leonardo({
|
|
41
37
|
security: {
|
|
42
38
|
bearerAuth: "Bearer YOUR_BEARER_TOKEN_HERE",
|
|
43
39
|
},
|
|
44
40
|
});
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
sdk.dataset.createDataset({
|
|
47
43
|
description: "corrupti",
|
|
48
44
|
name: "Kelvin Sporer",
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
}).then((res: CreateDatasetResponse) => {
|
|
46
|
+
if (res.statusCode == 200) {
|
|
47
|
+
// handle response
|
|
48
|
+
}
|
|
53
49
|
});
|
|
54
50
|
```
|
|
55
51
|
<!-- End SDK Example Usage -->
|
|
@@ -58,41 +54,41 @@ sdk.dataset.createDataset(req).then((res: CreateDatasetResponse | AxiosError) =>
|
|
|
58
54
|
## Available Resources and Operations
|
|
59
55
|
|
|
60
56
|
|
|
61
|
-
### dataset
|
|
57
|
+
### [dataset](docs/dataset/README.md)
|
|
62
58
|
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
59
|
+
* [createDataset](docs/dataset/README.md#createdataset) - Create a Dataset
|
|
60
|
+
* [deleteDatasetById](docs/dataset/README.md#deletedatasetbyid) - Delete a Single Dataset by ID
|
|
61
|
+
* [getDatasetById](docs/dataset/README.md#getdatasetbyid) - Get a Single Dataset by ID
|
|
62
|
+
* [uploadDatasetImage](docs/dataset/README.md#uploaddatasetimage) - Upload dataset image
|
|
63
|
+
* [uploadDatasetImageFromGen](docs/dataset/README.md#uploaddatasetimagefromgen) - Upload a Single Generated Image to a Dataset
|
|
68
64
|
|
|
69
|
-
### generation
|
|
65
|
+
### [generation](docs/generation/README.md)
|
|
70
66
|
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
67
|
+
* [createGeneration](docs/generation/README.md#creategeneration) - Create a Generation of Images
|
|
68
|
+
* [deleteGenerationById](docs/generation/README.md#deletegenerationbyid) - Delete a Single Generation
|
|
69
|
+
* [getGenerationById](docs/generation/README.md#getgenerationbyid) - Get a Single Generation
|
|
70
|
+
* [getGenerationsByUserId](docs/generation/README.md#getgenerationsbyuserid) - Get generations by user ID
|
|
75
71
|
|
|
76
|
-
### initImage
|
|
72
|
+
### [initImage](docs/initimage/README.md)
|
|
77
73
|
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
74
|
+
* [deleteInitImageById](docs/initimage/README.md#deleteinitimagebyid) - Delete init image
|
|
75
|
+
* [getInitImageById](docs/initimage/README.md#getinitimagebyid) - Get single init image
|
|
76
|
+
* [uploadInitImage](docs/initimage/README.md#uploadinitimage) - Upload init image
|
|
81
77
|
|
|
82
|
-
### model
|
|
78
|
+
### [model](docs/model/README.md)
|
|
83
79
|
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
80
|
+
* [createModel](docs/model/README.md#createmodel) - Train a Custom Model
|
|
81
|
+
* [deleteModelById](docs/model/README.md#deletemodelbyid) - Delete a Single Custom Model by ID
|
|
82
|
+
* [getModelById](docs/model/README.md#getmodelbyid) - Get a Single Custom Model by ID
|
|
87
83
|
|
|
88
|
-
### user
|
|
84
|
+
### [user](docs/user/README.md)
|
|
89
85
|
|
|
90
|
-
*
|
|
86
|
+
* [getUserSelf](docs/user/README.md#getuserself) - Get user information
|
|
91
87
|
|
|
92
|
-
### variation
|
|
88
|
+
### [variation](docs/variation/README.md)
|
|
93
89
|
|
|
94
|
-
*
|
|
95
|
-
*
|
|
90
|
+
* [createVariationUpscale](docs/variation/README.md#createvariationupscale) - Create upscale
|
|
91
|
+
* [getVariationById](docs/variation/README.md#getvariationbyid) - Get variation by ID
|
|
96
92
|
<!-- End SDK Available Operations -->
|
|
97
93
|
|
|
98
94
|
### SDK Generated by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks)
|
package/dist/sdk/dataset.js
CHANGED
|
@@ -36,6 +36,42 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
36
36
|
__setModuleDefault(result, mod);
|
|
37
37
|
return result;
|
|
38
38
|
};
|
|
39
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
40
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
41
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
42
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
43
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
44
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
45
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
49
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
50
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
51
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
52
|
+
function step(op) {
|
|
53
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
54
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
55
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
56
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
57
|
+
switch (op[0]) {
|
|
58
|
+
case 0: case 1: t = op; break;
|
|
59
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
60
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
61
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
62
|
+
default:
|
|
63
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
64
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
65
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
66
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
67
|
+
if (t[2]) _.ops.pop();
|
|
68
|
+
_.trys.pop(); continue;
|
|
69
|
+
}
|
|
70
|
+
op = body.call(thisArg, _);
|
|
71
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
72
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
73
|
+
}
|
|
74
|
+
};
|
|
39
75
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
76
|
exports.Dataset = void 0;
|
|
41
77
|
var utils = __importStar(require("../internal/utils"));
|
|
@@ -56,44 +92,53 @@ var Dataset = /** @class */ (function () {
|
|
|
56
92
|
* This endpoint creates a new dataset
|
|
57
93
|
*/
|
|
58
94
|
Dataset.prototype.createDataset = function (req, config) {
|
|
59
|
-
var _a;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
var _a, _b;
|
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
+
var baseURL, url, _c, reqBodyHeaders, reqBody, client, headers, httpRes, contentType, res;
|
|
98
|
+
var _d;
|
|
99
|
+
return __generator(this, function (_e) {
|
|
100
|
+
switch (_e.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
if (!(req instanceof utils.SpeakeasyBase)) {
|
|
103
|
+
req = new operations.CreateDatasetRequestBody(req);
|
|
104
|
+
}
|
|
105
|
+
baseURL = this._serverURL;
|
|
106
|
+
url = baseURL.replace(/\/$/, "") + "/datasets";
|
|
107
|
+
_c = [{}, {}], reqBodyHeaders = _c[0], reqBody = _c[1];
|
|
108
|
+
try {
|
|
109
|
+
_d = utils.serializeRequestBody(req, "request", "json"), reqBodyHeaders = _d[0], reqBody = _d[1];
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
if (e instanceof Error) {
|
|
113
|
+
throw new Error("Error serializing request body, cause: ".concat(e.message));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
client = this._securityClient || this._defaultClient;
|
|
117
|
+
headers = __assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers);
|
|
118
|
+
if (reqBody == null || Object.keys(reqBody).length === 0)
|
|
119
|
+
throw new Error("request body is required");
|
|
120
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "post", headers: headers, data: reqBody }, config))];
|
|
121
|
+
case 1:
|
|
122
|
+
httpRes = _e.sent();
|
|
123
|
+
contentType = (_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 : "";
|
|
124
|
+
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
125
|
+
throw new Error("status code not found in response: ".concat(httpRes));
|
|
126
|
+
}
|
|
127
|
+
res = new operations.CreateDatasetResponse({
|
|
128
|
+
statusCode: httpRes.status,
|
|
129
|
+
contentType: contentType,
|
|
130
|
+
rawResponse: httpRes,
|
|
131
|
+
});
|
|
132
|
+
switch (true) {
|
|
133
|
+
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
134
|
+
if (utils.matchContentType(contentType, "application/json")) {
|
|
135
|
+
res.createDataset200ApplicationJSONObject = utils.objectToClass(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, operations.CreateDataset200ApplicationJSON);
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
return [2 /*return*/, res];
|
|
140
|
+
}
|
|
88
141
|
});
|
|
89
|
-
switch (true) {
|
|
90
|
-
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
91
|
-
if (utils.matchContentType(contentType, "application/json")) {
|
|
92
|
-
res.createDataset200ApplicationJSONObject = utils.objectToClass(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, operations.CreateDataset200ApplicationJSON);
|
|
93
|
-
}
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
return res;
|
|
97
142
|
});
|
|
98
143
|
};
|
|
99
144
|
/**
|
|
@@ -103,31 +148,40 @@ var Dataset = /** @class */ (function () {
|
|
|
103
148
|
* This endpoint deletes the specific dataset
|
|
104
149
|
*/
|
|
105
150
|
Dataset.prototype.deleteDatasetById = function (req, config) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
151
|
+
var _a, _b;
|
|
152
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
153
|
+
var baseURL, url, client, httpRes, contentType, res;
|
|
154
|
+
return __generator(this, function (_c) {
|
|
155
|
+
switch (_c.label) {
|
|
156
|
+
case 0:
|
|
157
|
+
if (!(req instanceof utils.SpeakeasyBase)) {
|
|
158
|
+
req = new operations.DeleteDatasetByIdRequest(req);
|
|
159
|
+
}
|
|
160
|
+
baseURL = this._serverURL;
|
|
161
|
+
url = utils.generateURL(baseURL, "/datasets/{id}", req);
|
|
162
|
+
client = this._securityClient || this._defaultClient;
|
|
163
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "delete" }, config))];
|
|
164
|
+
case 1:
|
|
165
|
+
httpRes = _c.sent();
|
|
166
|
+
contentType = (_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 : "";
|
|
167
|
+
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
168
|
+
throw new Error("status code not found in response: ".concat(httpRes));
|
|
169
|
+
}
|
|
170
|
+
res = new operations.DeleteDatasetByIdResponse({
|
|
171
|
+
statusCode: httpRes.status,
|
|
172
|
+
contentType: contentType,
|
|
173
|
+
rawResponse: httpRes,
|
|
174
|
+
});
|
|
175
|
+
switch (true) {
|
|
176
|
+
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
177
|
+
if (utils.matchContentType(contentType, "application/json")) {
|
|
178
|
+
res.deleteDatasetById200ApplicationJSONObject = utils.objectToClass(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, operations.DeleteDatasetById200ApplicationJSON);
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
return [2 /*return*/, res];
|
|
183
|
+
}
|
|
122
184
|
});
|
|
123
|
-
switch (true) {
|
|
124
|
-
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
125
|
-
if (utils.matchContentType(contentType, "application/json")) {
|
|
126
|
-
res.deleteDatasetById200ApplicationJSONObject = utils.objectToClass(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, operations.DeleteDatasetById200ApplicationJSON);
|
|
127
|
-
}
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
return res;
|
|
131
185
|
});
|
|
132
186
|
};
|
|
133
187
|
/**
|
|
@@ -137,31 +191,40 @@ var Dataset = /** @class */ (function () {
|
|
|
137
191
|
* This endpoint gets the specific dataset
|
|
138
192
|
*/
|
|
139
193
|
Dataset.prototype.getDatasetById = function (req, config) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
194
|
+
var _a, _b;
|
|
195
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
196
|
+
var baseURL, url, client, httpRes, contentType, res;
|
|
197
|
+
return __generator(this, function (_c) {
|
|
198
|
+
switch (_c.label) {
|
|
199
|
+
case 0:
|
|
200
|
+
if (!(req instanceof utils.SpeakeasyBase)) {
|
|
201
|
+
req = new operations.GetDatasetByIdRequest(req);
|
|
202
|
+
}
|
|
203
|
+
baseURL = this._serverURL;
|
|
204
|
+
url = utils.generateURL(baseURL, "/datasets/{id}", req);
|
|
205
|
+
client = this._securityClient || this._defaultClient;
|
|
206
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "get" }, config))];
|
|
207
|
+
case 1:
|
|
208
|
+
httpRes = _c.sent();
|
|
209
|
+
contentType = (_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 : "";
|
|
210
|
+
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
211
|
+
throw new Error("status code not found in response: ".concat(httpRes));
|
|
212
|
+
}
|
|
213
|
+
res = new operations.GetDatasetByIdResponse({
|
|
214
|
+
statusCode: httpRes.status,
|
|
215
|
+
contentType: contentType,
|
|
216
|
+
rawResponse: httpRes,
|
|
217
|
+
});
|
|
218
|
+
switch (true) {
|
|
219
|
+
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
220
|
+
if (utils.matchContentType(contentType, "application/json")) {
|
|
221
|
+
res.getDatasetById200ApplicationJSONObject = utils.objectToClass(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, operations.GetDatasetById200ApplicationJSON);
|
|
222
|
+
}
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
return [2 /*return*/, res];
|
|
226
|
+
}
|
|
156
227
|
});
|
|
157
|
-
switch (true) {
|
|
158
|
-
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
159
|
-
if (utils.matchContentType(contentType, "application/json")) {
|
|
160
|
-
res.getDatasetById200ApplicationJSONObject = utils.objectToClass(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, operations.GetDatasetById200ApplicationJSON);
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
return res;
|
|
165
228
|
});
|
|
166
229
|
};
|
|
167
230
|
/**
|
|
@@ -171,45 +234,53 @@ var Dataset = /** @class */ (function () {
|
|
|
171
234
|
* This endpoint returns presigned details to upload a dataset image to S3
|
|
172
235
|
*/
|
|
173
236
|
Dataset.prototype.uploadDatasetImage = function (req, config) {
|
|
174
|
-
var _a;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
237
|
+
var _a, _b;
|
|
238
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
+
var baseURL, url, _c, reqBodyHeaders, reqBody, client, headers, httpRes, contentType, res;
|
|
240
|
+
var _d;
|
|
241
|
+
return __generator(this, function (_e) {
|
|
242
|
+
switch (_e.label) {
|
|
243
|
+
case 0:
|
|
244
|
+
if (!(req instanceof utils.SpeakeasyBase)) {
|
|
245
|
+
req = new operations.UploadDatasetImageRequest(req);
|
|
246
|
+
}
|
|
247
|
+
baseURL = this._serverURL;
|
|
248
|
+
url = utils.generateURL(baseURL, "/datasets/{datasetId}/upload", req);
|
|
249
|
+
_c = [{}, {}], reqBodyHeaders = _c[0], reqBody = _c[1];
|
|
250
|
+
try {
|
|
251
|
+
_d = utils.serializeRequestBody(req, "requestBody", "json"), reqBodyHeaders = _d[0], reqBody = _d[1];
|
|
252
|
+
}
|
|
253
|
+
catch (e) {
|
|
254
|
+
if (e instanceof Error) {
|
|
255
|
+
throw new Error("Error serializing request body, cause: ".concat(e.message));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
client = this._securityClient || this._defaultClient;
|
|
259
|
+
headers = __assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers);
|
|
260
|
+
if (reqBody == null || Object.keys(reqBody).length === 0)
|
|
261
|
+
throw new Error("request body is required");
|
|
262
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "post", headers: headers, data: reqBody }, config))];
|
|
263
|
+
case 1:
|
|
264
|
+
httpRes = _e.sent();
|
|
265
|
+
contentType = (_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 : "";
|
|
266
|
+
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
267
|
+
throw new Error("status code not found in response: ".concat(httpRes));
|
|
268
|
+
}
|
|
269
|
+
res = new operations.UploadDatasetImageResponse({
|
|
270
|
+
statusCode: httpRes.status,
|
|
271
|
+
contentType: contentType,
|
|
272
|
+
rawResponse: httpRes,
|
|
273
|
+
});
|
|
274
|
+
switch (true) {
|
|
275
|
+
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
276
|
+
if (utils.matchContentType(contentType, "application/json")) {
|
|
277
|
+
res.uploadDatasetImage200ApplicationJSONObject = utils.objectToClass(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, operations.UploadDatasetImage200ApplicationJSON);
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
return [2 /*return*/, res];
|
|
282
|
+
}
|
|
203
283
|
});
|
|
204
|
-
switch (true) {
|
|
205
|
-
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
206
|
-
if (utils.matchContentType(contentType, "application/json")) {
|
|
207
|
-
res.uploadDatasetImage200ApplicationJSONObject =
|
|
208
|
-
utils.objectToClass(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, operations.UploadDatasetImage200ApplicationJSON);
|
|
209
|
-
}
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
return res;
|
|
213
284
|
});
|
|
214
285
|
};
|
|
215
286
|
/**
|
|
@@ -219,45 +290,54 @@ var Dataset = /** @class */ (function () {
|
|
|
219
290
|
* This endpoint will upload a previously generated image to the dataset
|
|
220
291
|
*/
|
|
221
292
|
Dataset.prototype.uploadDatasetImageFromGen = function (req, config) {
|
|
222
|
-
var _a;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
293
|
+
var _a, _b;
|
|
294
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
295
|
+
var baseURL, url, _c, reqBodyHeaders, reqBody, client, headers, httpRes, contentType, res;
|
|
296
|
+
var _d;
|
|
297
|
+
return __generator(this, function (_e) {
|
|
298
|
+
switch (_e.label) {
|
|
299
|
+
case 0:
|
|
300
|
+
if (!(req instanceof utils.SpeakeasyBase)) {
|
|
301
|
+
req = new operations.UploadDatasetImageFromGenRequest(req);
|
|
302
|
+
}
|
|
303
|
+
baseURL = this._serverURL;
|
|
304
|
+
url = utils.generateURL(baseURL, "/datasets/{datasetId}/upload/gen", req);
|
|
305
|
+
_c = [{}, {}], reqBodyHeaders = _c[0], reqBody = _c[1];
|
|
306
|
+
try {
|
|
307
|
+
_d = utils.serializeRequestBody(req, "requestBody", "json"), reqBodyHeaders = _d[0], reqBody = _d[1];
|
|
308
|
+
}
|
|
309
|
+
catch (e) {
|
|
310
|
+
if (e instanceof Error) {
|
|
311
|
+
throw new Error("Error serializing request body, cause: ".concat(e.message));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
client = this._securityClient || this._defaultClient;
|
|
315
|
+
headers = __assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers);
|
|
316
|
+
if (reqBody == null || Object.keys(reqBody).length === 0)
|
|
317
|
+
throw new Error("request body is required");
|
|
318
|
+
return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "post", headers: headers, data: reqBody }, config))];
|
|
319
|
+
case 1:
|
|
320
|
+
httpRes = _e.sent();
|
|
321
|
+
contentType = (_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 : "";
|
|
322
|
+
if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
|
|
323
|
+
throw new Error("status code not found in response: ".concat(httpRes));
|
|
324
|
+
}
|
|
325
|
+
res = new operations.UploadDatasetImageFromGenResponse({
|
|
326
|
+
statusCode: httpRes.status,
|
|
327
|
+
contentType: contentType,
|
|
328
|
+
rawResponse: httpRes,
|
|
329
|
+
});
|
|
330
|
+
switch (true) {
|
|
331
|
+
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
332
|
+
if (utils.matchContentType(contentType, "application/json")) {
|
|
333
|
+
res.uploadDatasetImageFromGen200ApplicationJSONObject =
|
|
334
|
+
utils.objectToClass(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, operations.UploadDatasetImageFromGen200ApplicationJSON);
|
|
335
|
+
}
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
return [2 /*return*/, res];
|
|
339
|
+
}
|
|
251
340
|
});
|
|
252
|
-
switch (true) {
|
|
253
|
-
case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
|
|
254
|
-
if (utils.matchContentType(contentType, "application/json")) {
|
|
255
|
-
res.uploadDatasetImageFromGen200ApplicationJSONObject =
|
|
256
|
-
utils.objectToClass(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, operations.UploadDatasetImageFromGen200ApplicationJSON);
|
|
257
|
-
}
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
return res;
|
|
261
341
|
});
|
|
262
342
|
};
|
|
263
343
|
return Dataset;
|