Skip to content

Commit 03257ae

Browse files
authored
Update api contracts (#25)
1 parent eb46d09 commit 03257ae

4 files changed

Lines changed: 201 additions & 29 deletions

File tree

openapi-specs/component-catalog-v1.0.0.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ paths:
834834
schema:
835835
$ref: '#/components/schemas/ProvisioningDeleteRequest'
836836
responses:
837-
"200":
837+
"204":
838838
description: Project component properly deleted.
839839
"400":
840840
description: Bad request.
@@ -1347,4 +1347,4 @@ components:
13471347
type: string
13481348
example:
13491349
- "production"
1350-
- "staging"
1350+
- "staging"

openapi-specs/component-provisioner-v1.0.0.yaml

Lines changed: 194 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ paths:
140140
- ProvisionResults
141141
summary: Notify provisioning Status Update
142142
description: >
143-
This endpoint receives provisioning status update notifications from AWX.
143+
This endpoint receives provisioning updates.
144144
operationId: notifyProvisioningStatusUpdate
145145
parameters:
146146
- name: projectKey
@@ -162,20 +162,46 @@ paths:
162162
content:
163163
application/json:
164164
schema:
165-
type: object
166-
properties:
167-
componentId:
168-
type: string
169-
description: The componentId set by the user.
170-
example: "any-component-id-from-backend"
171-
catalogItemId:
172-
type: string
173-
description: The base64 encoded path for the catalogItem. Mind that it may include branch reference.
174-
example: "cHJvamVjdHMvQ0FURVNUL3JlcG9zL3VzZXItYWN0aW9ucy1pdGVtL3Jhdy9DYXRhbG9nSXRlbS55YW1sP2F0PXJlZnMvaGVhZHMvbWFzdGVy"
175-
componentUrl:
176-
type: string
177-
description: The bitbucket repository url for the provisioned component.
178-
example: "https://bitbucket.com/projects/myproject/repos/repo_name"
165+
$ref: '#/components/schemas/ProvisioningStatusUpdateRequest'
166+
responses:
167+
"200":
168+
description: Provisioning completion notified.
169+
"400":
170+
description: Bad request.
171+
"401":
172+
description: Invalid client token on the request.
173+
"403":
174+
description: Insufficient permissions for the client to access the resource.
175+
"500":
176+
description: Server error.
177+
patch:
178+
tags:
179+
- ProvisionResults
180+
summary: Notify provisioning Status Update
181+
description: >
182+
This endpoint receives provisioning status update notifications from AAP.
183+
operationId: notifyProvisioningStatusUpdatePartially
184+
parameters:
185+
- name: projectKey
186+
in: path
187+
description: Project key of the provisioned component.
188+
required: true
189+
schema:
190+
type: string
191+
- name: status
192+
in: path
193+
description: Project key of the provisioned component.
194+
required: true
195+
example: CREATING
196+
schema:
197+
type: string
198+
enum: [ CREATING, CREATED, FAILED, DELETING, UNKNOWN ]
199+
requestBody:
200+
required: true
201+
content:
202+
application/json:
203+
schema:
204+
$ref: '#/components/schemas/ProvisioningStatusPartialUpdateRequest'
179205
responses:
180206
"200":
181207
description: Provisioning completion notified.
@@ -194,10 +220,10 @@ paths:
194220
- basicAuth: [ ] # Enable ONLY basicAuth
195221
tags:
196222
- ProvisionResults
197-
summary: Delete provision status component from the file
223+
summary: Delete project component from the file
198224
description: >
199-
This endpoint receives provisioning status delete notifications from Component Provisioner.
200-
operationId: deleteProvisioningStatus
225+
This endpoint receives provisioning status delete notifications from Project Component.
226+
operationId: deleteProjectComponent
201227
parameters:
202228
- name: projectKey
203229
in: path
@@ -212,7 +238,7 @@ paths:
212238
schema:
213239
$ref: '#/components/schemas/ProvisioningDeleteRequest'
214240
responses:
215-
"200":
241+
"204":
216242
description: Project component properly deleted.
217243
"400":
218244
description: Bad request.
@@ -223,14 +249,14 @@ paths:
223249
"500":
224250
description: Server error.
225251

226-
/support/delete/{projectKey}/{componentId}:
252+
/provision/delete/{projectKey}/{componentId}:
227253
post:
228254
tags:
229255
- ProvisionResults
230256
summary: Request App Support to do operations to delete provision status component (and dependencies) from the file
231257
description: >
232258
This endpoint receives project key and componentId and send an create an incident to app support.
233-
operationId: createIncident
259+
operationId: requestDeletion
234260
parameters:
235261
- name: projectKey
236262
in: path
@@ -265,6 +291,51 @@ paths:
265291
description: Insufficient permissions for the client to access the resource.
266292
"500":
267293
description: Server error.
294+
295+
/project/{projectKey}/component/{componentId}:
296+
get:
297+
tags:
298+
- Project-components-with-provision-status
299+
summary: Returns the provision status of a project component given both its project key and component ID.
300+
operationId: getProjectComponentProvisionStatusById
301+
parameters:
302+
- name: projectKey
303+
in: path
304+
description: project key.
305+
required: true
306+
schema:
307+
type: string
308+
- name: componentId
309+
in: path
310+
description: component ID.
311+
required: true
312+
schema:
313+
type: string
314+
responses:
315+
"200":
316+
description: The provision status information of a project component, including fail reason if exists.
317+
content:
318+
application/json:
319+
schema:
320+
$ref: '#/components/schemas/ProjectComponentProvisionStatus'
321+
"401":
322+
description: Invalid client token on the request.
323+
content:
324+
application/json:
325+
schema:
326+
$ref: '#/components/schemas/RestErrorMessage'
327+
"403":
328+
description: Insufficient permissions for the client to access the resource.
329+
content:
330+
application/json:
331+
schema:
332+
$ref: '#/components/schemas/RestErrorMessage'
333+
"500":
334+
description: Server error.
335+
content:
336+
application/json:
337+
schema:
338+
$ref: '#/components/schemas/RestErrorMessage'
268339
components:
269340
securitySchemes:
270341
bearerAuth:
@@ -383,6 +454,61 @@ components:
383454
required:
384455
- message
385456

457+
ProvisioningStatusPartialUpdateRequest:
458+
type: object
459+
properties:
460+
componentId:
461+
type: string
462+
minLength: 1 # disallows empty string ""
463+
pattern: '^(?!\s*$).+' # reject whitespace-only
464+
description: The componentId set by the user.
465+
example: "any-component-id-from-backend"
466+
catalogItemId:
467+
type: string
468+
description: The base64 encoded path for the catalogItem. It may include branch reference.
469+
example: "cHJvamVjdHMvQ0FURVNUL3JlcG9zL3VzZXItYWN0aW9ucy1pdGVtL3Jhdy9DYXRhbG9nSXRlbS55YW1sP2F0PXJlZnMvaGVhZHMvbWFzdGVy"
470+
catalogItemSlug:
471+
type: string
472+
description: The slug for the provisioned component.
473+
example: "myproject_repo_name"
474+
componentUrl:
475+
type: string
476+
description: the repository url where the component was provisioned
477+
example: "https://bitbucket.com/projects/DEVSTACK/repos/devstack-component-catalog"
478+
nullable: true
479+
480+
ProvisioningStatusUpdateRequest:
481+
allOf:
482+
- $ref: '#/components/schemas/ProvisioningStatusPartialUpdateRequest'
483+
- type: object
484+
properties:
485+
workflowJobId:
486+
type: string
487+
description: the workflow job id from AWX to correlate provisioning status with AWX job status updates
488+
example: "123456"
489+
nullable: true
490+
parameters:
491+
type: array
492+
description: List of name/value string parameters.
493+
items:
494+
type: object
495+
required:
496+
- name
497+
- values
498+
properties:
499+
name:
500+
type: string
501+
description: Parameter name
502+
example: "environment"
503+
values:
504+
type: array
505+
description: Parameter values
506+
items:
507+
type: string
508+
example:
509+
- "production"
510+
- "staging"
511+
386512
ProvisioningDeleteRequest:
387513
type: object
388514
properties:
@@ -408,4 +534,50 @@ components:
408534
example:
409535
name: "workflow"
410536
type: "string"
411-
value: "2558"
537+
value: "2558"
538+
539+
ProjectComponentStatusParameter:
540+
properties:
541+
name:
542+
type: string
543+
example: 'environment'
544+
values:
545+
type: array
546+
items:
547+
type: string
548+
example:
549+
- 'dev'
550+
- 'test'
551+
ProjectComponentProvisionStatus:
552+
properties:
553+
projectKey:
554+
type: string
555+
example: 'simple-project-sample'
556+
componentId:
557+
type: string
558+
example: 'nextjs-basic-app'
559+
catalogItemId:
560+
type: string
561+
example: 'some-encoded-info'
562+
catalogItemRef:
563+
type: string
564+
example: 'more-encoded-info'
565+
status:
566+
type: string
567+
example: 'CREATING'
568+
componentUrl:
569+
type: string
570+
example: 'https://bitbucket.com/projects/CATALOGS/repos/project-components/browse/projects'
571+
workflowJobId:
572+
type: string
573+
example: '1316315'
574+
errorTask:
575+
type: string
576+
example: '08-01-fail if validations or checks did not pass'
577+
errorMessage:
578+
type: string
579+
example: 'JIRA_ERROR'
580+
parameters:
581+
type: array
582+
items:
583+
$ref: '#/components/schemas/ProjectComponentStatusParameter'

src/app/services/provisioner.service.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('ProvisionerService', () => {
1616

1717
beforeEach(() => {
1818
localStorage.clear();
19-
provisionResultsServiceSpy = jasmine.createSpyObj('ProvisionResultsService', ['createIncident']);
19+
provisionResultsServiceSpy = jasmine.createSpyObj('ProvisionResultsService', ['requestDeletion']);
2020

2121
TestBed.configureTestingModule({
2222
providers: [
@@ -26,7 +26,7 @@ describe('ProvisionerService', () => {
2626
]
2727
});
2828

29-
provisionResultsServiceSpy.createIncident.and.returnValue(of({} as any));
29+
provisionResultsServiceSpy.requestDeletion.and.returnValue(of({} as any));
3030

3131
service = TestBed.inject(ProvisionerService);
3232
});
@@ -39,7 +39,7 @@ describe('ProvisionerService', () => {
3939
expect(service).toBeTruthy();
4040
});
4141

42-
it('requestComponentDeletion should call createIncident with correct parameters', fakeAsync(() => {
42+
it('requestComponentDeletion should call requestDeletion with correct parameters', fakeAsync(() => {
4343
const projectKey = 'TEST_PROJECT';
4444
const componentName = 'TEST_COMPONENT';
4545
const username = 'test-user';
@@ -64,7 +64,7 @@ describe('ProvisionerService', () => {
6464
parameters: incidentParams
6565
} as CreateIncidentAction;
6666

67-
expect(provisionResultsServiceSpy.createIncident).toHaveBeenCalledWith(projectKey,componentName,expectedAction);
67+
expect(provisionResultsServiceSpy.requestDeletion).toHaveBeenCalledWith(projectKey,componentName,expectedAction);
6868
}));
6969

7070
});

src/app/services/provisioner.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ProvisionerService {
1717
parameters: incidentParams
1818
};
1919
/* eslint-enable @typescript-eslint/no-wrapper-object-types */
20-
return this.provisionerResultService.createIncident(projectKey, componentId, action).pipe(
20+
return this.provisionerResultService.requestDeletion(projectKey, componentId, action).pipe(
2121
// The API returns a 201 on success, so we map it to void
2222
// If there's an error, it will be propagated as an error in the Observable
2323
map(() => {})

0 commit comments

Comments
 (0)