mirror of
https://github.com/yldio/copilot.git
synced 2024-11-13 06:40:06 +02:00
Update frontend to use updated schema
This commit is contained in:
parent
4b2e0f53ae
commit
11751129b3
@ -5,6 +5,7 @@
|
||||
"dependencies": {
|
||||
"apollo": "^0.2.2",
|
||||
"babel-plugin-inline-react-svg": "^0.4.0",
|
||||
"babel-plugin-styled-components": "^1.1.4",
|
||||
"constant-case": "^2.0.0",
|
||||
"graphql-tag": "^2.0.0",
|
||||
"loadash": "^0.0.1",
|
||||
|
@ -23,7 +23,9 @@ module.exports = function(config) {
|
||||
query: {
|
||||
babelrc: false,
|
||||
presets: [require.resolve('babel-preset-react-app')],
|
||||
plugins: ["inline-react-svg"],
|
||||
plugins: [["inline-react-svg", {
|
||||
"ignorePattern": "libre-franklin"
|
||||
}]],
|
||||
cacheDirectory: true
|
||||
}
|
||||
})
|
||||
|
@ -45,7 +45,7 @@ const DeploymentGroupList = ({
|
||||
return (
|
||||
<p key={index}>
|
||||
<Link
|
||||
to={`${location.pathname}/${deploymentGroup.pathName}/services`}
|
||||
to={`${location.pathname}/${deploymentGroup.slug}/services`}
|
||||
>
|
||||
{deploymentGroup.name}
|
||||
</Link>
|
||||
|
@ -33,7 +33,7 @@ const InstanceListWithData = graphql(InstancesQuery, {
|
||||
options(props) {
|
||||
return {
|
||||
variables: {
|
||||
deploymentGroupId: props.match.params.deploymentGroup
|
||||
deploymentGroupSlug: props.match.params.deploymentGroup
|
||||
}
|
||||
};
|
||||
},
|
||||
|
@ -38,23 +38,23 @@ const ConnectedBreadcrumb = connect(
|
||||
(state, ownProps) => {
|
||||
|
||||
const params = ownProps.match.params;
|
||||
const deploymentGroupPathName = params.deploymentGroup;
|
||||
const servicePathName = params.service;
|
||||
const deploymentGroupSlug = params.deploymentGroup;
|
||||
const serviceSlug = params.service;
|
||||
const apolloData = state.apollo.data;
|
||||
const keys = Object.keys(apolloData);
|
||||
|
||||
let deploymentGroup, service;
|
||||
if(keys.length) {
|
||||
// These should be selectors
|
||||
if(deploymentGroupPathName) {
|
||||
if(deploymentGroupSlug) {
|
||||
deploymentGroup = keys.reduce((dg, k) =>
|
||||
apolloData[k].__typename === 'DeploymentGroup' &&
|
||||
apolloData[k].pathName === deploymentGroupPathName ?
|
||||
apolloData[k].slug === deploymentGroupSlug ?
|
||||
apolloData[k] : dg, {});
|
||||
if(servicePathName) {
|
||||
if(serviceSlug) {
|
||||
service = keys.reduce((s, k) =>
|
||||
apolloData[k].__typename === 'Service' &&
|
||||
apolloData[k].pathName === servicePathName ?
|
||||
apolloData[k].slug === serviceSlug ?
|
||||
apolloData[k] : s, {});
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,12 @@ const ConnectedMenu = connect(
|
||||
|
||||
const params = ownProps.match.params;
|
||||
const matchUrl = ownProps.match.url;
|
||||
const deploymentGroupPathName = params.deploymentGroup;
|
||||
const servicePathName = params.service;
|
||||
const deploymentGroupSlug = params.deploymentGroup;
|
||||
const serviceSlug = params.service;
|
||||
|
||||
const sections = servicePathName ?
|
||||
const sections = serviceSlug ?
|
||||
state.ui.sections.services :
|
||||
deploymentGroupPathName ?
|
||||
deploymentGroupSlug ?
|
||||
state.ui.sections.deploymentGroups :
|
||||
null;
|
||||
|
||||
|
@ -1,2 +1 @@
|
||||
export { default as ServiceMetrics } from './metrics';
|
||||
export { default as SingleMetrics } from './single-metrics';
|
||||
|
||||
|
@ -1,56 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import { graphql } from 'react-apollo';
|
||||
import MetricsQuery from '@graphql/Metrics.gql';
|
||||
|
||||
class Metrics extends Component {
|
||||
|
||||
render() {
|
||||
|
||||
const {
|
||||
instances,
|
||||
metrics
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<h4>Metrics</h4>
|
||||
<p>{JSON.stringify(metrics)}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const MetricsWithData = graphql(MetricsQuery, {
|
||||
options(props) {
|
||||
return {
|
||||
variables: {
|
||||
deploymentGroupId: props.match.params.deploymentGroup
|
||||
}
|
||||
};
|
||||
},
|
||||
props: ({ data: { deploymentGroup, loading, error } }) => {
|
||||
|
||||
const instances = deploymentGroup && deploymentGroup.services ?
|
||||
deploymentGroup.services.reduce((instances, service) =>
|
||||
instances.concat(service.instances), []) : null;
|
||||
|
||||
const metrics = instances ? instances.reduce((metrics, instance) =>
|
||||
metrics.concat(instance.metrics.map((m) =>
|
||||
Object.assign({}, m, {
|
||||
instance: {
|
||||
uuid: instance.uuid,
|
||||
name: instance.name
|
||||
}}))), []) : null;
|
||||
|
||||
return ({
|
||||
instances,
|
||||
metrics,
|
||||
loading,
|
||||
error
|
||||
})
|
||||
}
|
||||
})(Metrics)
|
||||
|
||||
export default MetricsWithData;
|
@ -1,35 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import { graphql } from 'react-apollo';
|
||||
import SingleMetricsQuery from '@graphql/SingleMetrics.gql';
|
||||
|
||||
class SingleMetrics extends Component {
|
||||
|
||||
render() {
|
||||
|
||||
const {
|
||||
metrics
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<h4>Metrics</h4>
|
||||
<p>{JSON.stringify(metrics)}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const SingleMetricsWithData = graphql(SingleMetricsQuery, {
|
||||
options: {
|
||||
pollInterval: 15*1000
|
||||
},
|
||||
props: ({ data: { instanceMetric, loading, error } }) => ({
|
||||
metrics: instanceMetric,
|
||||
loading,
|
||||
error
|
||||
})
|
||||
})(SingleMetrics)
|
||||
|
||||
export default SingleMetricsWithData;
|
@ -20,7 +20,7 @@ class ServiceList extends Component {
|
||||
services.map((service, index) =>
|
||||
<p key={index}>
|
||||
<Link
|
||||
to={`${location.pathname}/${service.id}/instances`}
|
||||
to={`${location.pathname.replace('services-list', 'services')}/${service.slug}/instances`}
|
||||
>
|
||||
{service.name}
|
||||
</Link>
|
||||
@ -41,7 +41,7 @@ const ServiceListWithData = graphql(ServicesQuery, {
|
||||
options(props) {
|
||||
return {
|
||||
variables: {
|
||||
deploymentGroupPathName: props.match.params.deploymentGroup
|
||||
deploymentGroupSlug: props.match.params.deploymentGroup
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -32,12 +32,6 @@ const ServicesTopology = ({
|
||||
error
|
||||
}) => {
|
||||
|
||||
console.log('push = ', push);
|
||||
console.log('services = ', services);
|
||||
console.log('datacenter = ', datacenter);
|
||||
console.log('loading = ', loading);
|
||||
console.log('error = ', error);
|
||||
|
||||
if(loading) {
|
||||
return (
|
||||
<LayoutContainer>
|
||||
@ -62,9 +56,9 @@ const ServicesTopology = ({
|
||||
const getService = (s, i) => ({
|
||||
index: i,
|
||||
...s,
|
||||
metrics: s.currentMetrics.map((m) => ({
|
||||
name: m.name,
|
||||
value: `${m.value}${m.measurement}`
|
||||
metrics: [1, 2, 3].map((m) => ({
|
||||
name: `${m}`,
|
||||
value: `${m}`
|
||||
})),
|
||||
instances: s.instances.length,
|
||||
datacenter: datacenter
|
||||
@ -115,7 +109,7 @@ const ServicesGql = graphql(ServicesQuery, {
|
||||
options(props) {
|
||||
return {
|
||||
variables: {
|
||||
deploymentGroupPathName: props.match.params.deploymentGroup
|
||||
deploymentGroupSlug: props.match.params.deploymentGroup
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2,7 +2,8 @@ query Portal {
|
||||
portal {
|
||||
username
|
||||
datacenter {
|
||||
id
|
||||
uuid
|
||||
region
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,6 @@ query Instances($deploymentGroupSlug: String!){
|
||||
...ServiceInfo
|
||||
parent
|
||||
connections
|
||||
currentMetrics {
|
||||
name
|
||||
value
|
||||
measurement
|
||||
}
|
||||
instances {
|
||||
uuid
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ import { DeploymentGroupList } from '@containers/deployment-groups';
|
||||
import { ServiceList, ServicesTopology, ServicesMenu } from '@containers/services';
|
||||
import { InstanceList } from '@containers/instances';
|
||||
|
||||
import { ServiceMetrics, SingleMetrics } from '@containers/service';
|
||||
|
||||
const rootRedirect = (p) => (
|
||||
<Redirect to='/deployment-groups' />
|
||||
);
|
||||
@ -45,6 +43,7 @@ const Router = (
|
||||
|
||||
<Route path='/deployment-groups/:deploymentGroup' exact component={deploymentGroupRedirect} />
|
||||
<Route path='/deployment-groups/:deploymentGroup/services' exact component={deploymentGroupRedirect} />
|
||||
<Route path='/deployment-groups/:deploymentGroup/instances' exact component={InstanceList} />
|
||||
|
||||
<Route path={`/deployment-groups/:deploymentGroup/services-list`} exact component={ServicesMenu} />
|
||||
<Route path='/deployment-groups/:deploymentGroup/services-list' exact component={ServiceList} />
|
||||
@ -53,8 +52,6 @@ const Router = (
|
||||
<Route path={`/deployment-groups/:deploymentGroup/services-topology`} exact component={ServicesTopology} />
|
||||
|
||||
<Route path='/deployment-groups/:deploymentGroup/services/:service/instances' exact component={InstanceList} />
|
||||
<Route path='/deployment-groups/:deploymentGroup/services/:service/metrics' exact component={ServiceMetrics} />
|
||||
<Route path='/deployment-groups/:deploymentGroup/services/:service/single-metrics' exact component={SingleMetrics} />
|
||||
|
||||
</div>
|
||||
</BrowserRouter>
|
||||
|
@ -2,19 +2,19 @@ import { createSelector } from 'reselect';
|
||||
|
||||
const apollo = (state) => state.apollo;
|
||||
|
||||
const deploymentGroupById = (deploymentGroupPathName) => createSelector(
|
||||
const deploymentGroupById = (deploymentGroupSlug) => createSelector(
|
||||
[apollo],
|
||||
(apollo) => apollo ? Object.keys(apollo).reduce((dg, k) =>
|
||||
apollo[k].__typename === 'DeploymentGroup' &&
|
||||
apollo[k].pathName === deploymentGroupPathName ?
|
||||
apollo[k].slug === deploymentGroupSlug ?
|
||||
apollo[k] : dg, {}) : null
|
||||
);
|
||||
|
||||
const servicesById = (servicePathName) => createSelector(
|
||||
const servicesById = (serviceSlug) => createSelector(
|
||||
[apollo],
|
||||
(apollo) => apollo ? Object.keys(apollo).reduce((s, k) =>
|
||||
apollo[k].__typename === 'Service' &&
|
||||
apollo[k].pathName === servicePathName ?
|
||||
apollo[k].slug === serviceSlug ?
|
||||
apollo[k] : s, {}) : null
|
||||
);
|
||||
|
||||
|
@ -2,48 +2,18 @@ const state = {
|
||||
ui: {
|
||||
sections: {
|
||||
deploymentGroups: [{
|
||||
pathname: "feed",
|
||||
name: "Feed"
|
||||
}, {
|
||||
pathname: "services",
|
||||
name: "Services"
|
||||
}, {
|
||||
pathname: "instances",
|
||||
name: "Instances"
|
||||
}, {
|
||||
pathname: "rollback",
|
||||
name: "Rollback"
|
||||
}, {
|
||||
pathname: "manifest",
|
||||
name: "Manifest"
|
||||
}, {
|
||||
pathname: "settings",
|
||||
name: "Settings"
|
||||
}],
|
||||
services: [{
|
||||
pathname: "summary",
|
||||
name: "Summary"
|
||||
}, {
|
||||
pathname: "instances",
|
||||
name: "Insatnces"
|
||||
}, {
|
||||
pathname: "metrics",
|
||||
name: "Metrics"
|
||||
}, {
|
||||
pathname: "networks",
|
||||
name: "Networks"
|
||||
}, {
|
||||
pathname: "tags-metadata",
|
||||
name: "Tags / metadata"
|
||||
}, {
|
||||
pathname: "activity-feed",
|
||||
name: "Activity feed"
|
||||
}, {
|
||||
pathname: "manifest",
|
||||
name: "Manifest"
|
||||
}, {
|
||||
pathname: "firewall",
|
||||
name: "Firewall"
|
||||
name: "Instances"
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
|
||||
import { ApolloClient, createNetworkInterface } from 'react-apollo';
|
||||
import state from './state';
|
||||
// import uiReducer from './reducers/ui';
|
||||
|
||||
console.log('state = ', state);
|
||||
|
||||
export const client = new ApolloClient({
|
||||
dataIdFromObject: o => {
|
||||
const id = o.pathName ? o.pathName : o.id ? o.id : o.uuid ? o.uuid : o.timestamp ? o.timestamp : o.name ? o.name : 'apollo-cache-key-not-defined';
|
||||
const id = o.slug ? o.slug : o.id ? o.id : o.uuid ? o.uuid : o.timestamp ? o.timestamp : o.name ? o.name : 'apollo-cache-key-not-defined';
|
||||
return `${o.__typename}:${id}`;
|
||||
},
|
||||
networkInterface: createNetworkInterface({
|
||||
|
@ -514,6 +514,12 @@ babel-plugin-jest-hoist@^18.0.0:
|
||||
version "18.0.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-18.0.0.tgz#4150e70ecab560e6e7344adc849498072d34e12a"
|
||||
|
||||
babel-plugin-styled-components@^1.1.4:
|
||||
version "1.1.4"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-1.1.4.tgz#b0e6d5bb01059bc7ab9118d3d686f6472ee8e91f"
|
||||
dependencies:
|
||||
stylis "2.0.0"
|
||||
|
||||
babel-plugin-syntax-async-functions@^6.8.0:
|
||||
version "6.13.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
|
||||
@ -2002,10 +2008,6 @@ esprima@^2.6.0, esprima@^2.7.1:
|
||||
version "2.7.3"
|
||||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581"
|
||||
|
||||
esprima@^3.1.1:
|
||||
version "3.1.3"
|
||||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
|
||||
|
||||
esprima@~3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.0.0.tgz#53cf247acda77313e551c3aa2e73342d3fb4f7d9"
|
||||
@ -3207,14 +3209,7 @@ js-tokens@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7"
|
||||
|
||||
js-yaml@^3.4.3, js-yaml@^3.5.1, js-yaml@^3.7.0:
|
||||
version "3.8.4"
|
||||
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.4.tgz#520b4564f86573ba96662af85a8cafa7b4b5a6f6"
|
||||
dependencies:
|
||||
argparse "^1.0.7"
|
||||
esprima "^3.1.1"
|
||||
|
||||
js-yaml@~3.7.0:
|
||||
js-yaml@^3.4.3, js-yaml@^3.5.1, js-yaml@^3.7.0, js-yaml@~3.7.0:
|
||||
version "3.7.0"
|
||||
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80"
|
||||
dependencies:
|
||||
@ -5211,6 +5206,10 @@ styled-components@^1.4.6:
|
||||
prop-types "^15.5.4"
|
||||
supports-color "^3.1.2"
|
||||
|
||||
stylis@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/stylis/-/stylis-2.0.0.tgz#6785a6546bd73478799a67d49d67086953b50ad5"
|
||||
|
||||
supports-color@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
|
||||
|
@ -2,8 +2,11 @@ import { find, filter } from 'lodash';
|
||||
import data from './mock-data';
|
||||
import { normalMetricData, leakMetricData } from './mock-data/metrics';
|
||||
|
||||
const datacenters = data.datacenters.data;
|
||||
const portal = { username: 'juditgreskovits', host: 'dockerhost', datacenter: datacenters[0]};
|
||||
const datacenter = {
|
||||
uuid: 'datacenter-uuid',
|
||||
region: 'us-east-1'
|
||||
};
|
||||
const portal = { username: 'juditgreskovits', host: 'dockerhost', datacenter};
|
||||
const deploymentGroups = data.projects.data.map(p => {
|
||||
p.slug = p.id;
|
||||
return p;
|
||||
@ -127,10 +130,7 @@ const resolveFunctions = {
|
||||
},
|
||||
|
||||
datacenter() {
|
||||
return {
|
||||
uuid: 'datacenter-uuid',
|
||||
region: 'us-east-1'
|
||||
};
|
||||
return datacenter;
|
||||
},
|
||||
|
||||
/*metricTypes() {
|
||||
|
@ -0,0 +1,204 @@
|
||||
|
||||
scalar Date
|
||||
scalar Object
|
||||
|
||||
type Portal {
|
||||
username: String!
|
||||
datacenter: Datacenter!
|
||||
deploymentGroups: [DeploymentGroup]!
|
||||
}
|
||||
|
||||
type DeploymentGroup {
|
||||
uuid: ID!
|
||||
name: String!
|
||||
slug: String!
|
||||
services: [Service]!
|
||||
version: Version!
|
||||
history: [Version]!
|
||||
}
|
||||
|
||||
type ServiceScale {
|
||||
uuid: ID!
|
||||
serviceName: String!
|
||||
replicas: Int!
|
||||
}
|
||||
|
||||
enum ConvergenceActionType {
|
||||
NOOP
|
||||
CREATE
|
||||
RECREATE
|
||||
START
|
||||
}
|
||||
|
||||
type ConvergenceAction {
|
||||
uuid: String!
|
||||
type: ConvergenceActionType!
|
||||
service: String! # service name
|
||||
machines: [String]! # instance machine ids
|
||||
}
|
||||
|
||||
type StateConvergencePlan {
|
||||
uuid: 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 {
|
||||
uuid: String!
|
||||
created: Date!
|
||||
type: ManifestType!
|
||||
format: ManifestFormat!
|
||||
raw: String!
|
||||
obj: Object!
|
||||
}
|
||||
|
||||
# immutable
|
||||
type Service {
|
||||
uuid: 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 uuid
|
||||
package: Package! # we don't have this in current mock data
|
||||
}
|
||||
|
||||
# for metrics max / min (I guess)
|
||||
type Package {
|
||||
uuid: 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 {
|
||||
uuid: String!
|
||||
name: String!
|
||||
machineId: String!
|
||||
status: InstanceStatus!
|
||||
# metrics: [InstanceMetric]!
|
||||
}
|
||||
|
||||
type Datacenter {
|
||||
uuid: 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 {
|
||||
uuid: String!
|
||||
name: String!
|
||||
id: String!
|
||||
}
|
||||
|
||||
type MetricData {
|
||||
timestamp: Int!
|
||||
value: Float!
|
||||
}
|
||||
|
||||
# Need to review queries
|
||||
type Query {
|
||||
portal: Portal
|
||||
deploymentGroups: [DeploymentGroup]
|
||||
deploymentGroup(uuid: String, slug: String): DeploymentGroup
|
||||
services(deploymentGroupUuid: String, deploymentGroupSlug: String): [Service]
|
||||
service(uuid: String, slug: String): Service
|
||||
instances(serviceUuid: String, serviceSlug: String): [Instance]
|
||||
instance(uuid: 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
|
||||
deploymentGroups(name: String, slug: String): [DeploymentGroup]
|
||||
deploymentGroup(uuid: ID, name: String, slug: String): DeploymentGroup
|
||||
serviceScales(serviceName: String, versionUuid: ID): [ServiceScale]
|
||||
serviceScale(uuid: ID!): ServiceScale
|
||||
convergenceActions(type: ConvergenceActionType, service: String, versionUuid: ID): [ConvergenceAction]
|
||||
convergenceAction(uuid: ID!): ConvergenceAction
|
||||
stateConvergencePlans(running: Boolean, versionUuid: ID): [StateConvergencePlan]
|
||||
stateConvergencePlan(uuid: ID!): StateConvergencePlan
|
||||
versions(manifestUuid: ID, deploymentGroupUuid: ID): [Version]
|
||||
version(uuid: ID, manifestUuid: ID): Version
|
||||
manifests(type: String, deploymentGroupUuid: ID): [Manifest]
|
||||
manifest(uuid: ID!): Manifest
|
||||
services(name: String, slug: String, parentUuid: ID, deploymentGroupUuid: ID, deploymentGroupSlug: String): [Service]
|
||||
service(uuid: 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(uuid: ID!): Package
|
||||
instances(name: String!, machineId: ID, status: InstanceStatus, serviceUuid: ID, serviceSlug: String, deploymentGroupUuid: ID, deploymentGroupSlug: String): [Instance]
|
||||
instance(uuid: ID!): Instance
|
||||
datacenter(uuid: ID, region: String): Datacenter
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createDeploymentGroup(name: String!) : DeploymentGroup
|
||||
updateDeploymentGroup(uuid: ID!, name: String!) : DeploymentGroup
|
||||
|
||||
provisionManifest(deploymentGroupUuid: ID!, type: ManifestType!, format: ManifestFormat!, raw: String!) : Version
|
||||
scale(service: ID!, replicas: Int!) : Version
|
||||
|
||||
stopServices(uuids: [ID]!) : [Service]
|
||||
startServices(uuids: [ID]!) : [Service]
|
||||
restartServices(uuids: [ID]!) : [Service]
|
||||
deleteServices(uuids: [ID]!) : [Service]
|
||||
|
||||
stopInstances(uuids: [ID]!) : [Instance]
|
||||
startInstances(uuids: [ID]!) : [Instance]
|
||||
restartInstances(uuids: [ID]!) : [Instance]
|
||||
|
||||
# reprovision() ???
|
||||
}
|
@ -1,213 +1,9 @@
|
||||
import path from 'path';
|
||||
import { readFileSync } from 'fs';
|
||||
import { makeExecutableSchema } from 'graphql-tools';
|
||||
import resolvers from './resolvers';
|
||||
|
||||
const schema = `
|
||||
|
||||
scalar Date
|
||||
scalar Object
|
||||
|
||||
type Portal {
|
||||
username: String!
|
||||
datacenter: Datacenter!
|
||||
deploymentGroups: [DeploymentGroup]!
|
||||
}
|
||||
|
||||
type DeploymentGroup {
|
||||
uuid: ID!
|
||||
name: String!
|
||||
slug: String!
|
||||
services: [Service]!
|
||||
version: Version!
|
||||
history: [Version]!
|
||||
}
|
||||
|
||||
type ServiceScale {
|
||||
uuid: ID!
|
||||
serviceName: String!
|
||||
replicas: Int!
|
||||
}
|
||||
|
||||
enum ConvergenceActionType {
|
||||
NOOP
|
||||
CREATE
|
||||
RECREATE
|
||||
START
|
||||
}
|
||||
|
||||
type ConvergenceAction {
|
||||
uuid: String!
|
||||
type: ConvergenceActionType!
|
||||
service: String! # service name
|
||||
machines: [String]! # instance machine ids
|
||||
}
|
||||
|
||||
type StateConvergencePlan {
|
||||
uuid: 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 {
|
||||
uuid: String!
|
||||
created: Date!
|
||||
type: ManifestType!
|
||||
format: ManifestFormat!
|
||||
raw: String!
|
||||
obj: Object!
|
||||
}
|
||||
|
||||
# immutable
|
||||
type Service {
|
||||
uuid: 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 uuid
|
||||
package: Package! # we don't have this in current mock data
|
||||
}
|
||||
|
||||
# for metrics max / min (I guess)
|
||||
type Package {
|
||||
uuid: 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 {
|
||||
uuid: String!
|
||||
name: String!
|
||||
machineId: String!
|
||||
status: InstanceStatus!
|
||||
# metrics: [InstanceMetric]!
|
||||
}
|
||||
|
||||
type Datacenter {
|
||||
uuid: 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 {
|
||||
uuid: String!
|
||||
name: String!
|
||||
id: String!
|
||||
}
|
||||
|
||||
type MetricData {
|
||||
timestamp: Int!
|
||||
value: Float!
|
||||
}
|
||||
|
||||
# Need to review queries
|
||||
type Query {
|
||||
portal: Portal
|
||||
deploymentGroups: [DeploymentGroup]
|
||||
deploymentGroup(uuid: String, slug: String): DeploymentGroup
|
||||
services(deploymentGroupUuid: String, deploymentGroupSlug: String): [Service]
|
||||
service(uuid: String, slug: String): Service
|
||||
instances(serviceUuid: String, serviceSlug: String): [Instance]
|
||||
instance(uuid: 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
|
||||
deploymentGroups(name: String, slug: String): [DeploymentGroup]
|
||||
deploymentGroup(uuid: ID, name: String, slug: String): DeploymentGroup
|
||||
serviceScales(serviceName: String, versionUuid: ID): [ServiceScale]
|
||||
serviceScale(uuid: ID!): ServiceScale
|
||||
convergenceActions(type: ConvergenceActionType, service: String, versionUuid: ID): [ConvergenceAction]
|
||||
convergenceAction(uuid: ID!): ConvergenceAction
|
||||
stateConvergencePlans(running: Boolean, versionUuid: ID): [StateConvergencePlan]
|
||||
stateConvergencePlan(uuid: ID!): StateConvergencePlan
|
||||
versions(manifestUuid: ID, deploymentGroupUuid: ID): [Version]
|
||||
version(uuid: ID, manifestUuid: ID): Version
|
||||
manifests(type: String, deploymentGroupUuid: ID): [Manifest]
|
||||
manifest(uuid: ID!): Manifest
|
||||
services(name: String, slug: String, parentUuid: ID, deploymentGroupUuid: ID, deploymentGroupSlug: String): [Service]
|
||||
service(uuid: 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(uuid: ID!): Package
|
||||
instances(name: String!, machineId: ID, status: InstanceStatus, serviceUuid: ID, serviceSlug: String, deploymentGroupUuid: ID, deploymentGroupSlug: String): [Instance]
|
||||
instance(uuid: ID!): Instance
|
||||
datacenter(uuid: ID, region: String): Datacenter
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createDeploymentGroup(name: String!) : DeploymentGroup
|
||||
updateDeploymentGroup(uuid: ID!, name: String!) : DeploymentGroup
|
||||
|
||||
provisionManifest(deploymentGroupUuid: ID!, type: ManifestType!, format: ManifestFormat!, raw: String!) : Version
|
||||
scale(service: ID!, replicas: Int!) : Version
|
||||
|
||||
stopServices(uuids: [ID]!) : [Service]
|
||||
startServices(uuids: [ID]!) : [Service]
|
||||
restartServices(uuids: [ID]!) : [Service]
|
||||
deleteServices(uuids: [ID]!) : [Service]
|
||||
|
||||
stopInstances(uuids: [ID]!) : [Instance]
|
||||
startInstances(uuids: [ID]!) : [Instance]
|
||||
restartInstances(uuids: [ID]!) : [Instance]
|
||||
|
||||
# reprovision() ???
|
||||
}
|
||||
|
||||
`;
|
||||
const schema = readFileSync(path.join(__dirname, 'schema.gql'), 'utf8');
|
||||
|
||||
export default makeExecutableSchema({
|
||||
typeDefs: schema,
|
||||
|
Loading…
Reference in New Issue
Block a user