backendapi.js 5.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Externs for backend API and model objects. This should be kept in sync with the
 * backend code.
 *
 * Guidelines:
 *  - Model JSONs should have the same name as backend structs.
 *
 * @externs
 */

const backendApi = {};

27 28 29 30 31 32 33 34 35
/**
 * @typedef {{
 *   port: (number|null),
 *   protocol: string,
 *   targetPort: (number|null)
 * }}
 */
backendApi.PortMapping;

36 37 38 39 40 41 42 43
/**
 * @typedef {{
 *  key: string,
 *  value: string
 * }}
 */
backendApi.Label;

44 45
/**
 * @typedef {{
46
 *   containerImage: string,
47 48
 *   containerCommand: ?string,
 *   containerCommandArgs: ?string,
49 50
 *   isExternal: boolean,
 *   name: string,
51
 *   description: ?string,
52
 *   portMappings: !Array<!backendApi.PortMapping>,
53
 *   labels: !Array<!backendApi.Label>,
54
 *   replicas: number,
55
 *   namespace: string,
56 57
 *   memoryRequirement: ?string,
 *   cpuRequirement: ?number,
58
 *   runAsPrivileged: boolean,
59 60
 * }}
 */
61
backendApi.AppDeploymentSpec;
B
bryk 已提交
62

M
Marcin Maciaszczyk 已提交
63 64 65 66 67 68 69 70
/**
 * @typedef {{
 *   name: string,
 *   content: string
 * }}
 */
backendApi.AppDeploymentFromFileSpec;

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
/**
 * @typedef {{
 *   namespace: string,
 *   events: !Array<!backendApi.Event>
 * }}
 */
backendApi.Events;

/**
 * @typedef {{
 *   message: string,
 *   sourceComponent: string,
 *   sourceHost: string,
 *   object: string,
 *   count: number,
 *   firstSeen: string,
 *   lastSeen: string,
M
Marcin Maciaszczyk 已提交
88 89
 *   reason: string,
 *   type: string
90 91 92 93
 * }}
 */
backendApi.Event;

B
bryk 已提交
94 95
/**
 * @typedef {{
96
 *   replicationControllers: !Array<!backendApi.ReplicationController>
B
bryk 已提交
97 98
 * }}
 */
99
backendApi.ReplicationControllerList;
B
bryk 已提交
100

101 102 103 104 105 106 107 108
/**
 * @typedef {{
 *   reason: string,
 *   message: string
 * }}
 */
backendApi.PodEvent;

109 110 111 112 113 114
/**
 * @typedef {{
 *   current: number,
 *   desired: number,
 *   running: number,
 *   pending: number,
115 116
 *   failed: number,
 *   warnings: !Array<!backendApi.PodEvent>
117 118
 * }}
 */
119
backendApi.ReplicationControllerPodInfo;
120

B
bryk 已提交
121 122 123
/**
 * @typedef {{
 *   name: string,
124
 *   namespace: string,
125 126
 *   description: string,
 *   labels: !Object<string, string>,
127
 *   pods: !backendApi.ReplicationControllerPodInfo,
128
 *   containerImages: !Array<string>,
129
 *   creationTime: string,
130 131
 *   internalEndpoints: !Array<!backendApi.Endpoint>,
 *   externalEndpoints: !Array<!backendApi.Endpoint>
B
bryk 已提交
132 133
 * }}
 */
134
backendApi.ReplicationController;
135

136 137 138 139 140 141 142
/**
 * @typedef {{
 *   name: string,
 *   namespace: string,
 *   labels: !Object<string, string>,
 *   labelSelector: !Object<string, string>,
 *   containerImages: !Array<string>,
143 144
 *   podInfo: !backendApi.ReplicationControllerPodInfo,
 *   pods: !Array<!backendApi.ReplicationControllerPod>,
145 146
 *   services: !Array<!backendApi.ServiceDetail>,
 *   hasMetrics: boolean
147 148
 * }}
 */
149
backendApi.ReplicationControllerDetail;
150

151 152 153 154 155
/**
 * @typedef {{
 *   replicas: number
 * }}
 */
156
backendApi.ReplicationControllerSpec;
157

158 159 160 161
/**
 * @typedef {{
 *   name: string,
 *   startTime: ?string,
162
 *   status: string,
163
 *   podIP: string,
164
 *   nodeName: string,
165 166
 *   restartCount: number,
 *   metrics: {cpuUsage: ?number, memoryUsage: ?number}
167 168
 * }}
 */
169
backendApi.ReplicationControllerPod;
170

171 172
/**
 * @typedef {{
173
 *  name: string,
174 175
 *  internalEndpoint: !backendApi.Endpoint,
 *  externalEndpoints: !Array<!backendApi.Endpoint>,
176 177 178 179 180
 *  selector: !Object<string, string>
 * }}
 */
backendApi.ServiceDetail;

181 182 183 184 185 186 187 188
/**
 * @typedef {{
 *  host: string,
 *  ports: !Array<{port: number, protocol: string}>
 * }}
 */
backendApi.Endpoint;

189 190 191 192 193 194 195
/**
 * @typedef {{
 *   name: string
 * }}
 */
backendApi.NamespaceSpec;

196 197 198 199 200 201
/**
 * @typedef {{
 *   namespaces: !Array<string>
 * }}
 */
backendApi.NamespaceList;
202

203 204 205 206 207 208 209 210 211 212 213
/**
 * @typedef {{
 *   name: string,
 *   restartCount: number
 * }}
 */
backendApi.PodContainer;

/**
 * @typedef {{
 *   name: string,
214
 *   startTime: ?string,
215 216 217 218
 *   totalRestartCount: number,
 *   podContainers: !Array<!backendApi.PodContainer>
 * }}
 */
219
backendApi.ReplicationControllerPodWithContainers;
220 221 222

/**
 * @typedef {{
223
 *   pods: !Array<!backendApi.ReplicationControllerPodWithContainers>
224 225
 * }}
 */
226
backendApi.ReplicationControllerPods;
227 228 229 230 231

/**
 * @typedef {{
 *   podId: string,
 *   sinceTime: string,
B
bryk 已提交
232 233
 *   logs: !Array<string>,
 *   container: string
234 235 236
 * }}
 */
backendApi.Logs;
B
bryk 已提交
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251

/**
 * @typedef {{
 *   name: string,
 *   namespace: string
 * }}
 */
backendApi.AppNameValiditySpec;

/**
 * @typedef {{
 *   valid: boolean
 * }}
 */
backendApi.AppNameValidity;
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273

/**
 * @typedef {{
 *    protocols: !Array<string>
 * }}
 */
backendApi.Protocols;

/**
 * @typedef {{
 *    valid: boolean
 * }}
 */
backendApi.ProtocolValidity;

/**
 * @typedef {{
 *    protocol: string,
 *    isExternal: boolean
 * }}
 */
backendApi.ProtocolValiditySpec;
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289

/**
 *  @typedef {{
 *    name: string,
 *    namespace: string,
 *    data: string,
 *  }}
 */
backendApi.SecretSpec;

/**
 * @typedef {{
 *   secrets: !Array<string>
 * }}
 */
backendApi.SecretsList;