cloudapi-gql
Advanced tools
Comparing version 4.5.1 to 4.6.0
@@ -136,3 +136,7 @@ 'use strict'; | ||
return CloudApi('/images', { query }, request); | ||
const images = await CloudApi('/images', { query }, request); | ||
return images.map(({ tags, ...image}) => Object.assign(image, { | ||
tags: internals.toNameValues(tags) | ||
})) | ||
}, | ||
@@ -144,3 +148,4 @@ | ||
try { | ||
return await CloudApi(`/images/${id}`, {}, request); | ||
const { tags, ...image } = await CloudApi(`/images/${id}`, {}, request); | ||
return Object.assign(image, { tags: internals.toNameValues(tags) }); | ||
} catch (ex) { | ||
@@ -368,2 +373,22 @@ request.log(['error', 'image'], ex); | ||
createImageFromMachine: async (root, { tags, ...image }, request) => { | ||
const payload = { | ||
...image, | ||
tags: internals.fromNameValues(tags) | ||
}; | ||
const { id } = await CloudApi('/images', { method: 'post', payload }, request); | ||
return internals.resolvers.Query.image(root, { id }, request); | ||
}, | ||
updateImage: async (root, { id, tags, ...image }, request) => { | ||
const payload = { | ||
...image, | ||
tags: internals.fromNameValues(tags) | ||
}; | ||
await CloudApi(`/images/${id}?action=update`, { method: 'post', payload }, request); | ||
return internals.resolvers.Query.image(root, { id }, request); | ||
}, | ||
stopMachine: async (root, args, request) => { | ||
@@ -503,4 +528,4 @@ const { id } = args; | ||
deleteMachineTag: async (root, { id, tag }, request) => { | ||
await CloudApi(`/machines/${id}/tags/${encodeURIComponent(tag)}`, { method: 'delete' }, request); | ||
deleteMachineTag: async (root, { id, name }, request) => { | ||
await CloudApi(`/machines/${id}/tags/${encodeURIComponent(name)}`, { method: 'delete' }, request); | ||
return internals.resolvers.Query.machine(root, { id }, request); | ||
@@ -507,0 +532,0 @@ }, |
{ | ||
"name": "cloudapi-gql", | ||
"version": "4.5.1", | ||
"version": "4.6.0", | ||
"license": "MPL-2.0", | ||
@@ -5,0 +5,0 @@ "repository": "github:yldio/joyent-portal", |
Sorry, the diff of this file is not supported yet
221268
2424