Skip to content

Commit d19f802

Browse files
committed
Singularize api endpoints and urls (#763)
Applies to: #719
1 parent 76ea239 commit d19f802

File tree

54 files changed

+150
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+150
-219
lines changed

src/app/backend/handler/apihandler.go

Lines changed: 66 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -89,220 +89,150 @@ func CreateHttpApiHandler(client *client.Client, heapsterClient HeapsterClient,
8989
apiHandler := ApiHandler{client, heapsterClient, clientConfig, verber}
9090
wsContainer := restful.NewContainer()
9191

92-
deployWs := new(restful.WebService)
93-
deployWs.Filter(wsLogger)
94-
deployWs.Path("/api/v1/appdeployments").
92+
apiV1Ws := new(restful.WebService)
93+
apiV1Ws.Filter(wsLogger)
94+
apiV1Ws.Path("/api/v1").
9595
Consumes(restful.MIME_JSON).
9696
Produces(restful.MIME_JSON)
97-
deployWs.Route(
98-
deployWs.POST("").
97+
wsContainer.Add(apiV1Ws)
98+
99+
apiV1Ws.Route(
100+
apiV1Ws.POST("/appdeployment").
99101
To(apiHandler.handleDeploy).
100102
Reads(AppDeploymentSpec{}).
101103
Writes(AppDeploymentSpec{}))
102-
deployWs.Route(
103-
deployWs.POST("/validate/name").
104+
apiV1Ws.Route(
105+
apiV1Ws.POST("/appdeployment/validate/name").
104106
To(apiHandler.handleNameValidity).
105107
Reads(AppNameValiditySpec{}).
106108
Writes(AppNameValidity{}))
107-
deployWs.Route(
108-
deployWs.POST("/validate/imagereference").
109+
apiV1Ws.Route(
110+
apiV1Ws.POST("/appdeployment/validate/imagereference").
109111
To(apiHandler.handleImageReferenceValidity).
110112
Reads(ImageReferenceValiditySpec{}).
111113
Writes(ImageReferenceValidity{}))
112-
deployWs.Route(
113-
deployWs.POST("/validate/protocol").
114+
apiV1Ws.Route(
115+
apiV1Ws.POST("/appdeployment/validate/protocol").
114116
To(apiHandler.handleProtocolValidity).
115117
Reads(ProtocolValiditySpec{}).
116118
Writes(ProtocolValidity{}))
117-
deployWs.Route(
118-
deployWs.GET("/protocols").
119+
apiV1Ws.Route(
120+
apiV1Ws.GET("/appdeployment/protocols").
119121
To(apiHandler.handleGetAvailableProcotols).
120122
Writes(Protocols{}))
121-
wsContainer.Add(deployWs)
122123

123-
deployFromFileWs := new(restful.WebService)
124-
deployFromFileWs.Path("/api/v1/appdeploymentfromfile").
125-
Consumes(restful.MIME_JSON).
126-
Produces(restful.MIME_JSON)
127-
deployFromFileWs.Route(
128-
deployFromFileWs.POST("").
124+
apiV1Ws.Route(
125+
apiV1Ws.POST("/appdeploymentfromfile").
129126
To(apiHandler.handleDeployFromFile).
130127
Reads(AppDeploymentFromFileSpec{}).
131128
Writes(AppDeploymentFromFileResponse{}))
132-
wsContainer.Add(deployFromFileWs)
133129

134-
replicationControllerWs := new(restful.WebService)
135-
replicationControllerWs.Filter(wsLogger)
136-
replicationControllerWs.Path("/api/v1/replicationcontrollers").
137-
Consumes(restful.MIME_JSON).
138-
Produces(restful.MIME_JSON)
139-
replicationControllerWs.Route(
140-
replicationControllerWs.GET("").
130+
apiV1Ws.Route(
131+
apiV1Ws.GET("/replicationcontroller").
141132
To(apiHandler.handleGetReplicationControllerList).
142133
Writes(ReplicationControllerList{}))
143-
replicationControllerWs.Route(
144-
replicationControllerWs.GET("/{namespace}/{replicationController}").
134+
apiV1Ws.Route(
135+
apiV1Ws.GET("/replicationcontroller/{namespace}/{replicationController}").
145136
To(apiHandler.handleGetReplicationControllerDetail).
146137
Writes(ReplicationControllerDetail{}))
147-
replicationControllerWs.Route(
148-
replicationControllerWs.POST("/{namespace}/{replicationController}/update/pods").
138+
apiV1Ws.Route(
139+
apiV1Ws.POST("/replicationcontroller/{namespace}/{replicationController}/update/pod").
149140
To(apiHandler.handleUpdateReplicasCount).
150141
Reads(ReplicationControllerSpec{}))
151-
replicationControllerWs.Route(
152-
replicationControllerWs.DELETE("/{namespace}/{replicationController}").
142+
apiV1Ws.Route(
143+
apiV1Ws.DELETE("/replicationcontroller/{namespace}/{replicationController}").
153144
To(apiHandler.handleDeleteReplicationController))
154-
replicationControllerWs.Route(
155-
replicationControllerWs.GET("/pods/{namespace}/{replicationController}").
145+
apiV1Ws.Route(
146+
apiV1Ws.GET("/replicationcontroller/pod/{namespace}/{replicationController}").
156147
To(apiHandler.handleGetReplicationControllerPods).
157148
Writes(ReplicationControllerPods{}))
158-
wsContainer.Add(replicationControllerWs)
159149

160-
workloadsWs := new(restful.WebService)
161-
workloadsWs.Filter(wsLogger)
162-
workloadsWs.Path("/api/v1/workloads").
163-
Consumes(restful.MIME_JSON).
164-
Produces(restful.MIME_JSON)
165-
workloadsWs.Route(
166-
workloadsWs.GET("").
150+
apiV1Ws.Route(
151+
apiV1Ws.GET("/workload").
167152
To(apiHandler.handleGetWorkloads).
168153
Writes(workload.Workloads{}))
169-
wsContainer.Add(workloadsWs)
170154

171-
replicaSetsWs := new(restful.WebService)
172-
replicaSetsWs.Filter(wsLogger)
173-
replicaSetsWs.Path("/api/v1/replicasets").
174-
Consumes(restful.MIME_JSON).
175-
Produces(restful.MIME_JSON)
176-
replicaSetsWs.Route(
177-
replicaSetsWs.GET("").
155+
apiV1Ws.Route(
156+
apiV1Ws.GET("/replicaset").
178157
To(apiHandler.handleGetReplicaSets).
179158
Writes(replicaset.ReplicaSetList{}))
180-
replicaSetsWs.Route(
181-
replicaSetsWs.GET("/{namespace}/{replicaSet}").
159+
apiV1Ws.Route(
160+
apiV1Ws.GET("/replicaset/{namespace}/{replicaSet}").
182161
To(apiHandler.handleGetReplicaSetDetail).
183162
Writes(replicaset.ReplicaSetDetail{}))
184-
wsContainer.Add(replicaSetsWs)
185163

186-
podsWs := new(restful.WebService)
187-
podsWs.Filter(wsLogger)
188-
podsWs.Path("/api/v1/pods").
189-
Consumes(restful.MIME_JSON).
190-
Produces(restful.MIME_JSON)
191-
podsWs.Route(
192-
podsWs.GET("").
164+
apiV1Ws.Route(
165+
apiV1Ws.GET("/pod").
193166
To(apiHandler.handleGetPods).
194167
Writes(pod.PodList{}))
195-
podsWs.Route(
196-
podsWs.GET("/{namespace}/{pod}").
168+
apiV1Ws.Route(
169+
apiV1Ws.GET("/pod/{namespace}/{pod}").
197170
To(apiHandler.handleGetPodDetail).
198171
Writes(pod.PodDetail{}))
199-
wsContainer.Add(podsWs)
200172

201-
deploymentsWs := new(restful.WebService)
202-
deploymentsWs.Filter(wsLogger)
203-
deploymentsWs.Path("/api/v1/deployments").
204-
Consumes(restful.MIME_JSON).
205-
Produces(restful.MIME_JSON)
206-
deploymentsWs.Route(
207-
deploymentsWs.GET("").
173+
apiV1Ws.Route(
174+
apiV1Ws.GET("/deployment").
208175
To(apiHandler.handleGetDeployments).
209176
Writes(deployment.DeploymentList{}))
210-
wsContainer.Add(deploymentsWs)
211-
daemonSetWs := new(restful.WebService)
212-
daemonSetWs.Filter(wsLogger)
213-
daemonSetWs.Path("/api/v1/daemonsets").
214-
Consumes(restful.MIME_JSON).
215-
Produces(restful.MIME_JSON)
216-
daemonSetWs.Route(
217-
daemonSetWs.GET("").
177+
178+
apiV1Ws.Route(
179+
apiV1Ws.GET("/daemonset").
218180
To(apiHandler.handleGetDaemonSetList).
219181
Writes(daemonset.DaemonSetList{}))
220-
daemonSetWs.Route(
221-
daemonSetWs.GET("/{namespace}/{daemonSet}").
182+
apiV1Ws.Route(
183+
apiV1Ws.GET("/daemonset/{namespace}/{daemonSet}").
222184
To(apiHandler.handleGetDaemonSetDetail).
223185
Writes(daemonset.DaemonSetDetail{}))
224-
daemonSetWs.Route(
225-
daemonSetWs.DELETE("/{namespace}/{daemonSet}").
186+
apiV1Ws.Route(
187+
apiV1Ws.DELETE("/daemonset/{namespace}/{daemonSet}").
226188
To(apiHandler.handleDeleteDaemonSet))
227-
wsContainer.Add(daemonSetWs)
228189

229-
namespacesWs := new(restful.WebService)
230-
namespacesWs.Filter(wsLogger)
231-
namespacesWs.Path("/api/v1/namespaces").
232-
Consumes(restful.MIME_JSON).
233-
Produces(restful.MIME_JSON)
234-
namespacesWs.Route(
235-
namespacesWs.POST("").
190+
apiV1Ws.Route(
191+
apiV1Ws.POST("/namespace").
236192
To(apiHandler.handleCreateNamespace).
237193
Reads(NamespaceSpec{}).
238194
Writes(NamespaceSpec{}))
239-
namespacesWs.Route(
240-
namespacesWs.GET("").
195+
apiV1Ws.Route(
196+
apiV1Ws.GET("/namespace").
241197
To(apiHandler.handleGetNamespaces).
242198
Writes(NamespaceList{}))
243-
wsContainer.Add(namespacesWs)
244199

245-
logsWs := new(restful.WebService)
246-
logsWs.Filter(wsLogger)
247-
logsWs.Path("/api/v1/logs").
248-
Produces(restful.MIME_JSON)
249-
logsWs.Route(
250-
logsWs.GET("/{namespace}/{podId}").
200+
apiV1Ws.Route(
201+
apiV1Ws.GET("/log/{namespace}/{podId}").
251202
To(apiHandler.handleLogs).
252203
Writes(Logs{}))
253-
logsWs.Route(
254-
logsWs.GET("/{namespace}/{podId}/{container}").
204+
apiV1Ws.Route(
205+
apiV1Ws.GET("/log/{namespace}/{podId}/{container}").
255206
To(apiHandler.handleLogs).
256207
Writes(Logs{}))
257-
wsContainer.Add(logsWs)
258208

259-
eventsWs := new(restful.WebService)
260-
eventsWs.Filter(wsLogger)
261-
eventsWs.Path("/api/v1/events").
262-
Produces(restful.MIME_JSON)
263-
eventsWs.Route(
264-
eventsWs.GET("/{namespace}/{replicationController}").
209+
apiV1Ws.Route(
210+
apiV1Ws.GET("/event/{namespace}/{replicationController}").
265211
To(apiHandler.handleEvents).
266212
Writes(common.EventList{}))
267-
wsContainer.Add(eventsWs)
268213

269-
secretsWs := new(restful.WebService)
270-
secretsWs.Path("/api/v1/secrets").Produces(restful.MIME_JSON)
271-
secretsWs.Route(
272-
secretsWs.GET("/{namespace}").
214+
apiV1Ws.Route(
215+
apiV1Ws.GET("/secret/{namespace}").
273216
To(apiHandler.handleGetSecrets).
274217
Writes(SecretsList{}))
275-
secretsWs.Route(
276-
secretsWs.POST("").
218+
apiV1Ws.Route(
219+
apiV1Ws.POST("/secret").
277220
To(apiHandler.handleCreateImagePullSecret).
278221
Reads(ImagePullSecretSpec{}).
279222
Writes(Secret{}))
280-
wsContainer.Add(secretsWs)
281223

282-
servicesWs := new(restful.WebService)
283-
servicesWs.Filter(wsLogger)
284-
servicesWs.Path("/api/v1/services").
285-
Consumes(restful.MIME_JSON).
286-
Produces(restful.MIME_JSON)
287-
servicesWs.Route(
288-
servicesWs.GET("").
224+
apiV1Ws.Route(
225+
apiV1Ws.GET("/service").
289226
To(apiHandler.handleGetServiceList).
290227
Writes(resourceService.ServiceList{}))
291-
servicesWs.Route(
292-
servicesWs.GET("/{namespace}/{service}").
228+
apiV1Ws.Route(
229+
apiV1Ws.GET("/service/{namespace}/{service}").
293230
To(apiHandler.handleGetServiceDetail).
294231
Writes(resourceService.ServiceDetail{}))
295-
wsContainer.Add(servicesWs)
296232

297-
resourceVerberWs := new(restful.WebService)
298-
resourceVerberWs.Filter(wsLogger)
299-
resourceVerberWs.Path("/api/v1").
300-
Consumes(restful.MIME_JSON).
301-
Produces(restful.MIME_JSON)
302-
resourceVerberWs.Route(
303-
resourceVerberWs.DELETE("/{kind}/namespace/{namespace}/name/{name}").
233+
apiV1Ws.Route(
234+
apiV1Ws.DELETE("/{kind}/namespace/{namespace}/name/{name}").
304235
To(apiHandler.handleDeleteResource))
305-
wsContainer.Add(resourceVerberWs)
306236

307237
return wsContainer
308238
}

src/app/frontend/chrome/chrome.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<md-toolbar class="kd-toolbar">
1818
<div class="md-toolbar-tools kd-toolbar-tools">
19-
<a ui-sref="workloads" ui-sref-opts="{ reload: true }" tabindex="-1">
19+
<a ui-sref="workload" ui-sref-opts="{ reload: true }" tabindex="-1">
2020
<md-icon md-svg-icon="assets/images/kubernetes-logo.svg" class="kd-toolbar-logo"></md-icon>
2121
</a>
2222
<h2>

src/app/frontend/deploy/createnamespace_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default class NamespaceDialogController {
9292
let namespaceSpec = {name: this.namespace};
9393

9494
/** @type {!angular.Resource<!backendApi.NamespaceSpec>} */
95-
let resource = this.resource_('api/v1/namespaces');
95+
let resource = this.resource_('api/v1/namespace');
9696

9797
resource.save(
9898
namespaceSpec,

src/app/frontend/deploy/createsecret_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export default class CreateSecretController {
102102
data: this.data,
103103
};
104104
/** @type {!angular.Resource<!backendApi.SecretSpec>} */
105-
let resource = this.resource_(`api/v1/secrets/`);
105+
let resource = this.resource_(`api/v1/secret/`);
106106

107107
resource.save(
108108
secretSpec,

src/app/frontend/deploy/deploy_stateconfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function stateConfig($stateProvider) {
4242
*/
4343
function resolveNamespaces($resource) {
4444
/** @type {!angular.Resource<!backendApi.NamespaceList>} */
45-
let resource = $resource('api/v1/namespaces');
45+
let resource = $resource('api/v1/namespace');
4646

4747
return resource.get().$promise;
4848
}
@@ -53,7 +53,7 @@ function resolveNamespaces($resource) {
5353
* @ngInject
5454
*/
5555
function getProtocolsResource($resource) {
56-
return $resource('api/v1/appdeployments/protocols');
56+
return $resource('api/v1/appdeployment/protocols');
5757
}
5858

5959
/**

src/app/frontend/deploy/deployfromsettings_controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export default class DeployFromSettingsController {
214214
let defer = this.q_.defer();
215215

216216
/** @type {!angular.Resource<!backendApi.AppDeploymentSpec>} */
217-
let resource = this.resource_('api/v1/appdeployments');
217+
let resource = this.resource_('api/v1/appdeployment');
218218
resource.save(
219219
appDeploymentSpec,
220220
(savedConfig) => {
@@ -288,7 +288,7 @@ export default class DeployFromSettingsController {
288288
*/
289289
getSecrets(namespace) {
290290
/** @type {!angular.Resource<!backendApi.SecretsList>} */
291-
let resource = this.resource_(`api/v1/secrets/${namespace}`);
291+
let resource = this.resource_(`api/v1/secret/${namespace}`);
292292
resource.get(
293293
(res) => { this.secrets = res.secrets; },
294294
(err) => { this.log_.log(`Error getting secrets: ${err}`); });

src/app/frontend/deploy/uniquename_directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function validate(name, namespace, resource, q) {
5353
let deferred = q.defer();
5454

5555
/** @type {!angular.Resource<!backendApi.AppNameValiditySpec>} */
56-
let resourceClass = resource('api/v1/appdeployments/validate/name');
56+
let resourceClass = resource('api/v1/appdeployment/validate/name');
5757
/** @type {!backendApi.AppNameValiditySpec} */
5858
let spec = {name: name, namespace: namespace};
5959
resourceClass.save(

src/app/frontend/deploy/validimagereference_directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function validate(reference, scope, resource, q) {
5151
let deferred = q.defer();
5252

5353
/** @type {!angular.Resource<!backendApi.ImageReferenceValiditySpec>} */
54-
let resourceClass = resource('api/v1/appdeployments/validate/imagereference');
54+
let resourceClass = resource('api/v1/appdeployment/validate/imagereference');
5555
/** @type {!backendApi.ImageReferenceValiditySpec} */
5656
let spec = {reference: reference};
5757

src/app/frontend/deploy/validprotocol_directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function validate(ngModelController, externalChanged, protocol, isExternal, reso
6868
}
6969

7070
/** @type {!angular.Resource<!backendApi.ProtocolValiditySpec>} */
71-
let resourceClass = resource('api/v1/appdeployments/validate/protocol');
71+
let resourceClass = resource('api/v1/appdeployment/validate/protocol');
7272
/** @type {!backendApi.ProtocolValiditySpec} */
7373
let spec = {protocol: protocol, isExternal: isExternal};
7474
resourceClass.save(

src/app/frontend/deploymentdetail/deploymentdetail_stateconfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ import {stateName} from './deploymentdetail_state';
2222
*/
2323
export default function stateConfig($stateProvider) {
2424
$stateProvider.state(stateName, {
25-
url: '/deployments/:namespace/:deployment',
25+
url: '/deployment/:namespace/:deployment',
2626
});
2727
}

0 commit comments

Comments
 (0)