chore: remove legacy gql server
This commit is contained in:
parent
20b8b23cbb
commit
59043760b6
@ -1,257 +0,0 @@
|
||||
import { find, filter } from 'lodash';
|
||||
import data from './mock-data';
|
||||
import { normalMetricData, leakMetricData } from './mock-data/metrics';
|
||||
|
||||
// TMP / Util
|
||||
const datacenter = {
|
||||
id: 'datacenter-id',
|
||||
region: 'us-east-1'
|
||||
};
|
||||
const user = {
|
||||
id: 'unique-user-id',
|
||||
firstName: 'Judit',
|
||||
lastName: 'Greskovits',
|
||||
email: 'name@email.com',
|
||||
login: 'juditgreskovits'
|
||||
};
|
||||
const portal = { user, host: 'dockerhost', datacenter };
|
||||
const deploymentGroups = data.projects.data.map(p => {
|
||||
p.slug = p.id;
|
||||
p.id = p.uuid;
|
||||
return p;
|
||||
});
|
||||
const services = data.services.data.map(s => {
|
||||
s.slug = s.id;
|
||||
s.id = s.uuid;
|
||||
return s;
|
||||
});
|
||||
const instances = data.instances.data.map(i => {
|
||||
i.slug = i.id;
|
||||
i.id = i.uuid;
|
||||
return i;
|
||||
});
|
||||
const metricTypes = data.metrics.data.types;
|
||||
|
||||
const count = 10;
|
||||
let index = 0;
|
||||
const getInstanceMetricData = (dataset, type) => {
|
||||
return dataset[type].slice(index, index + count);
|
||||
};
|
||||
|
||||
const tick = setInterval(() => index++, 15 * 1000);
|
||||
|
||||
// GraphQL
|
||||
|
||||
const queries = {
|
||||
portal() {
|
||||
return portal;
|
||||
},
|
||||
|
||||
deploymentGroups(_, { name, slug }) {
|
||||
return deploymentGroups;
|
||||
},
|
||||
deploymentGroup(_, { id, name, slug }) {
|
||||
if (id) {
|
||||
return find(deploymentGroups, { id: id });
|
||||
}
|
||||
if (slug) {
|
||||
return find(deploymentGroups, { slug: slug });
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
serviceScales(_, { serviceName, versionUuid }) {
|
||||
// : [ServiceScale]
|
||||
return [];
|
||||
},
|
||||
serviceScale(_, { id }) {
|
||||
// : ServiceScale
|
||||
return {};
|
||||
},
|
||||
|
||||
convergenceActions(_, { type, service, versionUuid }) {
|
||||
// : [ConvergenceAction]
|
||||
return [];
|
||||
},
|
||||
convergenceAction(id) {
|
||||
// : ConvergenceAction
|
||||
return {};
|
||||
},
|
||||
|
||||
stateConvergencePlans(_, { running, versionUuid }) {
|
||||
// : [StateConvergencePlan]
|
||||
return [];
|
||||
},
|
||||
stateConvergencePlan(_, { id }) {
|
||||
// : StateConvergencePlan
|
||||
return [];
|
||||
},
|
||||
|
||||
versions(_, { manifestUuid, deploymentGroupUuid }) {
|
||||
// : [Version]
|
||||
return [];
|
||||
},
|
||||
version(_, { id, manifestUuid }) {
|
||||
// : Version
|
||||
return null;
|
||||
},
|
||||
|
||||
manifests(_, { type, deploymentGroupUuid }) {
|
||||
// : [Manifest]
|
||||
return [];
|
||||
},
|
||||
manifest(_, { id }) {
|
||||
// : Manifest
|
||||
return null;
|
||||
},
|
||||
|
||||
services(
|
||||
_,
|
||||
{ name, slug, parentUuid, deploymentGroupUuid, deploymentGroupSlug }
|
||||
) {
|
||||
// }: [Service]
|
||||
if (deploymentGroupUuid) {
|
||||
return filter(services, { project: deploymentGroupUuid });
|
||||
}
|
||||
if (deploymentGroupSlug) {
|
||||
const deploymentGroup = find(deploymentGroups, {
|
||||
slug: deploymentGroupSlug
|
||||
});
|
||||
if (deploymentGroup) {
|
||||
if (slug) {
|
||||
return filter(services, { project: deploymentGroup.id, slug: slug });
|
||||
}
|
||||
return filter(services, { project: deploymentGroup.id });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return services;
|
||||
},
|
||||
service(_, { id, hash }) {
|
||||
// : Service
|
||||
if (id) {
|
||||
return find(services, { id: id });
|
||||
}
|
||||
if (hash) {
|
||||
return find(services, { hash: hash });
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
packages(_, { name, type, memory, disk, swap, lwps, vcpus, version, group }) {
|
||||
// : [Package]
|
||||
return [];
|
||||
},
|
||||
package(_, { id }) {
|
||||
// : Package
|
||||
return {};
|
||||
},
|
||||
|
||||
instances(
|
||||
_,
|
||||
{
|
||||
name,
|
||||
machineId,
|
||||
status,
|
||||
serviceUuid,
|
||||
serviceSlug,
|
||||
deploymentGroupUuid,
|
||||
deploymentGroupSlug
|
||||
}
|
||||
) {
|
||||
// : [Instance]
|
||||
if (serviceUuid) {
|
||||
return filter(instances, { service: serviceUuid });
|
||||
}
|
||||
if (serviceSlug) {
|
||||
const service = find(services, { slug: serviceSlug });
|
||||
if (service) {
|
||||
return filter(instances, { service: service.id });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return instances;
|
||||
},
|
||||
instance(_, { id }) {
|
||||
// : Instance
|
||||
if (id) {
|
||||
return find(instances, { id: id });
|
||||
}
|
||||
},
|
||||
|
||||
datacenter() {
|
||||
return datacenter;
|
||||
}
|
||||
|
||||
/*metricTypes() {
|
||||
return metricTypes;
|
||||
},
|
||||
// tmp test
|
||||
instanceMetric() {
|
||||
return {
|
||||
type: {
|
||||
id: 'node_memory_rss_bytes',
|
||||
id: 'node_memory_rss_bytes',
|
||||
name: 'node_memory_rss_bytes',
|
||||
},
|
||||
data: getInstanceMetricData(leakMetricData, 'node_memory_rss_bytes')
|
||||
};
|
||||
}*/
|
||||
};
|
||||
|
||||
const resolveFunctions = {
|
||||
Query: queries,
|
||||
Portal: {
|
||||
deploymentGroups(portal, args, context) {
|
||||
return deploymentGroups;
|
||||
}
|
||||
},
|
||||
DeploymentGroup: {
|
||||
services(deploymentGroup, args, context) {
|
||||
const a = Object.assign({}, args, {
|
||||
deploymentGroupSlug: deploymentGroup.slug
|
||||
});
|
||||
return queries.services(null, a);
|
||||
}
|
||||
},
|
||||
Service: {
|
||||
instances(service, args, context) {
|
||||
return filter(instances, { service: service.id });
|
||||
}
|
||||
/*metrics(service) {
|
||||
return service.metrics ?
|
||||
service.metrics.map((metric) =>
|
||||
find(metricTypes, { id: metric.type })) : [];
|
||||
},*/
|
||||
/*currentMetrics(service) {
|
||||
// tmp
|
||||
return [{
|
||||
"name": "CPU",
|
||||
"value": 50,
|
||||
"measurement": "%",
|
||||
}, {
|
||||
"name": "Memory",
|
||||
"value": 20,
|
||||
"measurement": "%",
|
||||
}, {
|
||||
"name": "Network",
|
||||
"value": 2.9,
|
||||
"measurement": "Kb/sec",
|
||||
}];
|
||||
},*/
|
||||
}
|
||||
/*Instance: {
|
||||
metrics(instance) {
|
||||
return ([{
|
||||
type: {
|
||||
id: 'metric-type-id',
|
||||
id: 'metric-type-id',
|
||||
name: 'metric-type-name'
|
||||
},
|
||||
data: normalMetricData.node_memory_rss_bytes
|
||||
}]);
|
||||
}
|
||||
}*/
|
||||
};
|
||||
|
||||
export default resolveFunctions;
|
@ -1,213 +0,0 @@
|
||||
|
||||
scalar Date
|
||||
scalar Object
|
||||
|
||||
type Portal {
|
||||
user: User!
|
||||
datacenter: Datacenter!
|
||||
deploymentGroups: [DeploymentGroup]!
|
||||
}
|
||||
|
||||
type User {
|
||||
id: ID!
|
||||
firstName: String!
|
||||
lastName: String!
|
||||
email: String!
|
||||
login: String!
|
||||
}
|
||||
|
||||
type DeploymentGroup {
|
||||
id: ID!
|
||||
name: String!
|
||||
slug: String!
|
||||
services(slug: String): [Service]!
|
||||
version: Version!
|
||||
history: [Version]!
|
||||
}
|
||||
|
||||
type ServiceScale {
|
||||
id: ID!
|
||||
serviceName: String!
|
||||
replicas: Int!
|
||||
}
|
||||
|
||||
enum ConvergenceActionType {
|
||||
NOOP
|
||||
CREATE
|
||||
RECREATE
|
||||
START
|
||||
}
|
||||
|
||||
type ConvergenceAction {
|
||||
id: String!
|
||||
type: ConvergenceActionType!
|
||||
service: String! # service name
|
||||
machines: [String]! # instance machine ids
|
||||
}
|
||||
|
||||
type StateConvergencePlan {
|
||||
id: String!
|
||||
running: Boolean!
|
||||
actions: [ConvergenceAction]!
|
||||
}
|
||||
|
||||
type Version {
|
||||
created: Date! # Either Int or define scalar
|
||||
manifest: Manifest!
|
||||
scale: [ServiceScale]!
|
||||
plan: StateConvergencePlan
|
||||
}
|
||||
|
||||
enum ManifestType {
|
||||
COMPOSE
|
||||
MARIPOSA
|
||||
}
|
||||
|
||||
enum ManifestFormat {
|
||||
JSON
|
||||
YAML
|
||||
}
|
||||
|
||||
type Manifest {
|
||||
id: String!
|
||||
created: Date!
|
||||
type: ManifestType!
|
||||
format: ManifestFormat!
|
||||
raw: String!
|
||||
obj: Object!
|
||||
}
|
||||
|
||||
# immutable
|
||||
type Service {
|
||||
id: String! # unique id for db row
|
||||
hash: String! # unique id for version of service
|
||||
name: String! # human readable name
|
||||
slug: String!
|
||||
instances: [Instance]!
|
||||
# metrics: [MetricType]!
|
||||
currentMetrics: [CurrentMetric]!
|
||||
connections: [String!] # list of serviceUuids
|
||||
parent: ID # parent service id
|
||||
package: Package! # we don't have this in current mock data
|
||||
}
|
||||
|
||||
# for metrics max / min (I guess)
|
||||
type Package {
|
||||
id: ID!
|
||||
name: String!
|
||||
type: String!
|
||||
memory: Float!
|
||||
disk: Float!
|
||||
swap: Float!
|
||||
lwps: Int!
|
||||
vcpus: Int!
|
||||
version: String!
|
||||
group: String!
|
||||
}
|
||||
|
||||
enum InstanceStatus {
|
||||
CREATED
|
||||
RESTARTING
|
||||
RUNNING
|
||||
PAUSED
|
||||
EXITED
|
||||
DELETED
|
||||
}
|
||||
|
||||
type Instance {
|
||||
id: String!
|
||||
name: String!
|
||||
machineId: String!
|
||||
status: InstanceStatus!
|
||||
# metrics: [InstanceMetric]!
|
||||
}
|
||||
|
||||
type Datacenter {
|
||||
id: String!
|
||||
# name: String! # Do we have 'official' human readable names?
|
||||
region: String!
|
||||
}
|
||||
|
||||
type InstanceMetric {
|
||||
type: MetricType!
|
||||
data: [MetricData]!
|
||||
}
|
||||
|
||||
type CurrentMetric {
|
||||
name: String!
|
||||
value: Float!
|
||||
measurement: String!
|
||||
}
|
||||
|
||||
type MetricType {
|
||||
id: String!
|
||||
name: String!
|
||||
id: String!
|
||||
}
|
||||
|
||||
type MetricData {
|
||||
timestamp: Int!
|
||||
value: Float!
|
||||
}
|
||||
|
||||
# Need to review queries
|
||||
type Query {
|
||||
portal: Portal
|
||||
deploymentGroups: [DeploymentGroup]
|
||||
deploymentGroup(id: String, slug: String): DeploymentGroup
|
||||
services(deploymentGroupUuid: String, deploymentGroupSlug: String): [Service]
|
||||
service(id: String, slug: String): Service
|
||||
instances(serviceUuid: String, serviceSlug: String): [Instance]
|
||||
instance(id: String, machineId: String): Instance
|
||||
metricTypes: [MetricType]
|
||||
metricData(instanceUuid: String!, metricType: String!, from: Date!, to: Date!): [InstanceMetric]!
|
||||
package: Package
|
||||
datacenters: [Datacenter]
|
||||
# tmp test
|
||||
instanceMetric: InstanceMetric!
|
||||
}
|
||||
|
||||
# we probably wont use some of these queries or arguments
|
||||
# but this way we expose the entire db through gql
|
||||
type Query {
|
||||
portal: Portal
|
||||
user: User
|
||||
deploymentGroups(name: String, slug: String): [DeploymentGroup]
|
||||
deploymentGroup(id: ID, name: String, slug: String): DeploymentGroup
|
||||
serviceScales(serviceName: String, versionUuid: ID): [ServiceScale]
|
||||
serviceScale(id: ID!): ServiceScale
|
||||
convergenceActions(type: ConvergenceActionType, service: String, versionUuid: ID): [ConvergenceAction]
|
||||
convergenceAction(id: ID!): ConvergenceAction
|
||||
stateConvergencePlans(running: Boolean, versionUuid: ID): [StateConvergencePlan]
|
||||
stateConvergencePlan(id: ID!): StateConvergencePlan
|
||||
versions(manifestUuid: ID, deploymentGroupUuid: ID): [Version]
|
||||
version(id: ID, manifestUuid: ID): Version
|
||||
manifests(type: String, deploymentGroupUuid: ID): [Manifest]
|
||||
manifest(id: ID!): Manifest
|
||||
services(name: String, slug: String, parentUuid: ID, deploymentGroupUuid: ID, deploymentGroupSlug: String): [Service]
|
||||
service(id: ID, hash: ID): Service
|
||||
packages(name: String, type: String, memory: Int, disk: Int, swap: Int, lwps: Int, vcpus: Int, version: String, group: String): [Package]
|
||||
package(id: ID!): Package
|
||||
instances(name: String!, machineId: ID, status: InstanceStatus, serviceUuid: ID, serviceSlug: String, deploymentGroupUuid: ID, deploymentGroupSlug: String): [Instance]
|
||||
instance(id: ID!): Instance
|
||||
datacenter(id: ID, region: String): Datacenter
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createDeploymentGroup(name: String!) : DeploymentGroup
|
||||
updateDeploymentGroup(id: ID!, name: String!) : DeploymentGroup
|
||||
|
||||
provisionManifest(deploymentGroupUuid: ID!, type: ManifestType!, format: ManifestFormat!, raw: String!) : Version
|
||||
scale(service: ID!, replicas: Int!) : Version
|
||||
|
||||
stopServices(ids: [ID]!) : [Service]
|
||||
startServices(ids: [ID]!) : [Service]
|
||||
restartServices(ids: [ID]!) : [Service]
|
||||
deleteServices(ids: [ID]!) : [Service]
|
||||
|
||||
stopInstances(ids: [ID]!) : [Instance]
|
||||
startInstances(ids: [ID]!) : [Instance]
|
||||
restartInstances(ids: [ID]!) : [Instance]
|
||||
|
||||
# reprovision() ???
|
||||
}
|
Loading…
Reference in New Issue
Block a user