67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
const fs = require('fs');
|
|
async function test() {
|
|
const tokenData = JSON.parse(fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/token.json', 'utf8'));
|
|
const token = tokenData.token;
|
|
const userId = tokenData.userId;
|
|
console.log('User ID:', userId);
|
|
|
|
// 1. Resources
|
|
const q1 = {
|
|
query: `query GetResources($userId: uuid) {
|
|
ghaymah_cloud_resources(where: { user_id: { _eq: $userId }, deleted: { _eq: false } }) {
|
|
id
|
|
chart_name
|
|
chart_version
|
|
status
|
|
values
|
|
}
|
|
}`,
|
|
variables: { userId }
|
|
};
|
|
const res1 = await fetch('https://graphql.ghaymah.systems/v1/graphql', {
|
|
method: 'POST',
|
|
headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(q1)
|
|
});
|
|
console.log('Resources response:', JSON.stringify(await res1.json(), null, 2));
|
|
|
|
// 2. Managed Resources
|
|
const q2 = {
|
|
query: `query GetManagedResources($userId: uuid) {
|
|
ghaymah_cloud_managed_resources(where: { user_id: { _eq: $userId } }) {
|
|
id
|
|
values
|
|
status
|
|
}
|
|
}`,
|
|
variables: { userId }
|
|
};
|
|
const res2 = await fetch('https://graphql.ghaymah.systems/v1/graphql', {
|
|
method: 'POST',
|
|
headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(q2)
|
|
});
|
|
console.log('Managed Resources response:', JSON.stringify(await res2.json(), null, 2));
|
|
|
|
// 3. ListApps
|
|
const q3 = {
|
|
query: `mutation ListApps {
|
|
listApps {
|
|
id
|
|
name
|
|
image
|
|
status
|
|
alias
|
|
}
|
|
}`
|
|
};
|
|
const res3 = await fetch('https://graphql.ghaymah.systems/v1/graphql', {
|
|
method: 'POST',
|
|
headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(q3)
|
|
});
|
|
console.log('ListApps response:', JSON.stringify(await res3.json(), null, 2));
|
|
}
|
|
|
|
test().catch(console.error);
|