mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-20 19:49:18 +00:00
Update all API queries to use the v7 model
This commit is contained in:
parent
afd14794f5
commit
f0e0c0d728
@ -152,8 +152,7 @@ export const createRelease = async function (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// @balena/compose atm works with v6, bump it once @balena/compose moves to v7.
|
apiVersion: 'v7',
|
||||||
apiVersion: 'v6',
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ describe('balena deploy', function () {
|
|||||||
let failedImagePatchRequests = 0;
|
let failedImagePatchRequests = 0;
|
||||||
let succesfullImagePatchRequests = 0;
|
let succesfullImagePatchRequests = 0;
|
||||||
api
|
api
|
||||||
.optPatch(/^\/v6\/image($|[(?])/, { times: maxRequestRetries })
|
.optPatch(/^\/v7\/image($|[(?])/, { times: maxRequestRetries })
|
||||||
.reply((_uri, requestBody) => {
|
.reply((_uri, requestBody) => {
|
||||||
const imageBody = requestBody as Partial<
|
const imageBody = requestBody as Partial<
|
||||||
import('@balena/compose/dist/release/models').ImageModel
|
import('@balena/compose/dist/release/models').ImageModel
|
||||||
|
@ -46,7 +46,7 @@ describe('balena device', function () {
|
|||||||
it('should list device details for provided uuid', async () => {
|
it('should list device details for provided uuid', async () => {
|
||||||
api.scope
|
api.scope
|
||||||
.get(
|
.get(
|
||||||
/^\/v6\/device\?.+&\$expand=belongs_to__application\(\$select=app_name,slug\)/,
|
/^\/v7\/device\?.+&\$expand=belongs_to__application\(\$select=app_name,slug\)/,
|
||||||
)
|
)
|
||||||
.replyWithFile(200, path.join(apiResponsePath, 'device.json'), {
|
.replyWithFile(200, path.join(apiResponsePath, 'device.json'), {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -64,7 +64,7 @@ describe('balena device', function () {
|
|||||||
it.skip('correctly handles devices with missing fields', async () => {
|
it.skip('correctly handles devices with missing fields', async () => {
|
||||||
api.scope
|
api.scope
|
||||||
.get(
|
.get(
|
||||||
/^\/v6\/device\?.+&\$expand=belongs_to__application\(\$select=app_name,slug\)/,
|
/^\/v7\/device\?.+&\$expand=belongs_to__application\(\$select=app_name,slug\)/,
|
||||||
)
|
)
|
||||||
.replyWithFile(
|
.replyWithFile(
|
||||||
200,
|
200,
|
||||||
@ -88,7 +88,7 @@ describe('balena device', function () {
|
|||||||
// e.g. When user has a device associated with app that user is no longer a collaborator of.
|
// e.g. When user has a device associated with app that user is no longer a collaborator of.
|
||||||
api.scope
|
api.scope
|
||||||
.get(
|
.get(
|
||||||
/^\/v6\/device\?.+&\$expand=belongs_to__application\(\$select=app_name,slug\)/,
|
/^\/v7\/device\?.+&\$expand=belongs_to__application\(\$select=app_name,slug\)/,
|
||||||
)
|
)
|
||||||
.replyWithFile(
|
.replyWithFile(
|
||||||
200,
|
200,
|
||||||
@ -109,7 +109,7 @@ describe('balena device', function () {
|
|||||||
|
|
||||||
it('outputs device as JSON with the -j/--json flag', async () => {
|
it('outputs device as JSON with the -j/--json flag', async () => {
|
||||||
api.scope
|
api.scope
|
||||||
.get(/^\/v6\/device\?.+&\$expand=device_tag\(\$select=tag_key,value\)/)
|
.get(/^\/v7\/device\?.+&\$expand=device_tag\(\$select=tag_key,value\)/)
|
||||||
.replyWithFile(200, path.join(apiResponsePath, 'device.json'), {
|
.replyWithFile(200, path.join(apiResponsePath, 'device.json'), {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
});
|
});
|
||||||
@ -125,7 +125,7 @@ describe('balena device', function () {
|
|||||||
it('should list devices from own and collaborator apps', async () => {
|
it('should list devices from own and collaborator apps', async () => {
|
||||||
api.scope
|
api.scope
|
||||||
.get(
|
.get(
|
||||||
'/v6/device?$orderby=device_name%20asc&$select=id,uuid,device_name,status,is_online,supervisor_version,os_version&$expand=belongs_to__application($select=app_name,slug),is_of__device_type($select=slug),is_running__release($select=commit)',
|
'/v7/device?$orderby=device_name%20asc&$select=id,uuid,device_name,status,is_online,supervisor_version,os_version&$expand=belongs_to__application($select=app_name,slug),is_of__device_type($select=slug),is_running__release($select=commit)',
|
||||||
)
|
)
|
||||||
.replyWithFile(200, path.join(apiResponsePath, 'devices.json'), {
|
.replyWithFile(200, path.join(apiResponsePath, 'devices.json'), {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -39,7 +39,7 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
times = undefined as number | undefined,
|
times = undefined as number | undefined,
|
||||||
expandArchitecture = false,
|
expandArchitecture = false,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const interceptor = this.optGet(/^\/v6\/application($|[(?])/, {
|
const interceptor = this.optGet(/^\/v7\/application($|[(?])/, {
|
||||||
optional,
|
optional,
|
||||||
persist,
|
persist,
|
||||||
times,
|
times,
|
||||||
@ -52,8 +52,8 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
path.join(
|
path.join(
|
||||||
apiResponsePath,
|
apiResponsePath,
|
||||||
!expandArchitecture
|
!expandArchitecture
|
||||||
? 'application-GET-v6-expanded-app-type.json'
|
? 'application-GET-v7-expanded-app-type.json'
|
||||||
: 'application-GET-v6-expanded-app-type-cpu-arch.json',
|
: 'application-GET-v7-expanded-app-type-cpu-arch.json',
|
||||||
),
|
),
|
||||||
jHeader,
|
jHeader,
|
||||||
);
|
);
|
||||||
@ -87,7 +87,7 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public expectGetMyApplication(opts: ScopeOpts = {}) {
|
public expectGetMyApplication(opts: ScopeOpts = {}) {
|
||||||
this.optGet(/^\/v6\/my_application($|[(?])/, opts).reply(
|
this.optGet(/^\/v7\/my_application($|[(?])/, opts).reply(
|
||||||
200,
|
200,
|
||||||
JSON.parse(`{"d": [{
|
JSON.parse(`{"d": [{
|
||||||
"organization": [{ "handle": "bob", "__metadata": {} }],
|
"organization": [{ "handle": "bob", "__metadata": {} }],
|
||||||
@ -109,7 +109,7 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
persist = false,
|
persist = false,
|
||||||
times = undefined as number | undefined,
|
times = undefined as number | undefined,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const interceptor = this.optGet(/^\/v6\/release($|[(?])/, {
|
const interceptor = this.optGet(/^\/v7\/release($|[(?])/, {
|
||||||
persist,
|
persist,
|
||||||
optional,
|
optional,
|
||||||
times,
|
times,
|
||||||
@ -117,12 +117,12 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
if (notFound) {
|
if (notFound) {
|
||||||
interceptor.reply(200, { d: [] });
|
interceptor.reply(200, { d: [] });
|
||||||
} else {
|
} else {
|
||||||
this.optGet(/^\/v6\/release($|[(?])/, {
|
this.optGet(/^\/v7\/release($|[(?])/, {
|
||||||
persist,
|
persist,
|
||||||
optional,
|
optional,
|
||||||
}).replyWithFile(
|
}).replyWithFile(
|
||||||
200,
|
200,
|
||||||
path.join(apiResponsePath, 'release-GET-v6.json'),
|
path.join(apiResponsePath, 'release-GET-v7.json'),
|
||||||
jHeader,
|
jHeader,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
persist = false,
|
persist = false,
|
||||||
times = undefined as number | undefined,
|
times = undefined as number | undefined,
|
||||||
}) {
|
}) {
|
||||||
this.optPatch(/^\/v6\/release($|[(?])/, { optional, persist, times }).reply(
|
this.optPatch(/^\/v7\/release($|[(?])/, { optional, persist, times }).reply(
|
||||||
statusCode,
|
statusCode,
|
||||||
this.getInspectedReplyBodyFunction(inspectRequest, replyBody),
|
this.getInspectedReplyBodyFunction(inspectRequest, replyBody),
|
||||||
);
|
);
|
||||||
@ -155,11 +155,11 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
persist = false,
|
persist = false,
|
||||||
times = undefined as number | undefined,
|
times = undefined as number | undefined,
|
||||||
}) {
|
}) {
|
||||||
this.optPost(/^\/v6\/release($|[(?])/, { optional, persist, times }).reply(
|
this.optPost(/^\/v7\/release($|[(?])/, { optional, persist, times }).reply(
|
||||||
statusCode,
|
statusCode,
|
||||||
this.getInspectedReplyFileFunction(
|
this.getInspectedReplyFileFunction(
|
||||||
inspectRequest,
|
inspectRequest,
|
||||||
path.join(apiResponsePath, 'release-POST-v6.json'),
|
path.join(apiResponsePath, 'release-POST-v7.json'),
|
||||||
),
|
),
|
||||||
jHeader,
|
jHeader,
|
||||||
);
|
);
|
||||||
@ -176,7 +176,7 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
persist = false,
|
persist = false,
|
||||||
times = undefined as number | undefined,
|
times = undefined as number | undefined,
|
||||||
}) {
|
}) {
|
||||||
this.optPatch(/^\/v6\/image($|[(?])/, { optional, persist, times }).reply(
|
this.optPatch(/^\/v7\/image($|[(?])/, { optional, persist, times }).reply(
|
||||||
statusCode,
|
statusCode,
|
||||||
this.getInspectedReplyBodyFunction(inspectRequest, replyBody),
|
this.getInspectedReplyBodyFunction(inspectRequest, replyBody),
|
||||||
);
|
);
|
||||||
@ -186,9 +186,9 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
* Mocks balena-release call
|
* Mocks balena-release call
|
||||||
*/
|
*/
|
||||||
public expectPostImage(opts: ScopeOpts = {}) {
|
public expectPostImage(opts: ScopeOpts = {}) {
|
||||||
this.optPost(/^\/v6\/image($|[(?])/, opts).replyWithFile(
|
this.optPost(/^\/v7\/image($|[(?])/, opts).replyWithFile(
|
||||||
201,
|
201,
|
||||||
path.join(apiResponsePath, 'image-POST-v6.json'),
|
path.join(apiResponsePath, 'image-POST-v7.json'),
|
||||||
jHeader,
|
jHeader,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -197,9 +197,9 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
* Mocks balena-release call
|
* Mocks balena-release call
|
||||||
*/
|
*/
|
||||||
public expectPostImageLabel(opts: ScopeOpts = {}) {
|
public expectPostImageLabel(opts: ScopeOpts = {}) {
|
||||||
this.optPost(/^\/v6\/image_label($|[(?])/, opts).replyWithFile(
|
this.optPost(/^\/v7\/image_label($|[(?])/, opts).replyWithFile(
|
||||||
201,
|
201,
|
||||||
path.join(apiResponsePath, 'image-label-POST-v6.json'),
|
path.join(apiResponsePath, 'image-label-POST-v7.json'),
|
||||||
jHeader,
|
jHeader,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -209,11 +209,11 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
*/
|
*/
|
||||||
public expectPostImageIsPartOfRelease(opts: ScopeOpts = {}) {
|
public expectPostImageIsPartOfRelease(opts: ScopeOpts = {}) {
|
||||||
this.optPost(
|
this.optPost(
|
||||||
/^\/v6\/image__is_part_of__release($|[(?])/,
|
/^\/v7\/image__is_part_of__release($|[(?])/,
|
||||||
opts,
|
opts,
|
||||||
).replyWithFile(
|
).replyWithFile(
|
||||||
200,
|
200,
|
||||||
path.join(apiResponsePath, 'image-is-part-of-release-POST-v6.json'),
|
path.join(apiResponsePath, 'image-is-part-of-release-POST-v7.json'),
|
||||||
jHeader,
|
jHeader,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -365,7 +365,7 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
public expectGetDeviceTypes(opts: ScopeOpts = {}) {
|
public expectGetDeviceTypes(opts: ScopeOpts = {}) {
|
||||||
this.optGet(/^\/v\d+\/device_type($|\?)/, opts).replyWithFile(
|
this.optGet(/^\/v\d+\/device_type($|\?)/, opts).replyWithFile(
|
||||||
200,
|
200,
|
||||||
path.join(apiResponsePath, 'device-type-GET-v6.json'),
|
path.join(apiResponsePath, 'device-type-GET-v7.json'),
|
||||||
jHeader,
|
jHeader,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -404,7 +404,7 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
serviceName: string;
|
serviceName: string;
|
||||||
}) {
|
}) {
|
||||||
const serviceId = opts.serviceId || 243768;
|
const serviceId = opts.serviceId || 243768;
|
||||||
this.optGet(/^\/v6\/application($|\?).*\$expand=service.*/, opts).reply(
|
this.optGet(/^\/v7\/application($|\?).*\$expand=service.*/, opts).reply(
|
||||||
200,
|
200,
|
||||||
{
|
{
|
||||||
d: [{ service: [{ id: serviceId, service_name: opts.serviceName }] }],
|
d: [{ service: [{ id: serviceId, service_name: opts.serviceName }] }],
|
||||||
|
Loading…
Reference in New Issue
Block a user