Skip to content

Commit d5323ad

Browse files
authored
Update latest contracts with extra tokens (#20)
* Update latest contracts with extra tokens * Remove unused import
1 parent 507f570 commit d5323ad

7 files changed

Lines changed: 226 additions & 214 deletions

File tree

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

Lines changed: 166 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ paths:
4848
required: true
4949
schema:
5050
type: string
51-
- name: accessToken
52-
in: query
53-
description: access token for azure queries.
54-
required: true
55-
schema:
56-
type: string
5751
responses:
5852
"200":
5953
description: A list of Project Component Information
@@ -162,6 +156,72 @@ paths:
162156
application/json:
163157
schema:
164158
$ref: '#/components/schemas/RestErrorMessage'
159+
/catalog-items/slug/{slug}:
160+
get:
161+
tags:
162+
- CatalogItems
163+
summary: Returns the CatalogItem associated to the provided slug.
164+
description: >
165+
Returns the CatalogItem identified by a composite slug with format `{project-key}_{catalog-item-repository-name}`.<br/>
166+
The separator is the first underscore (`_`); everything after it (the repo name) may itself contain underscores.<br/>
167+
The project-key is the normalised (lowercase) Bitbucket project key that owns the item's repository.
168+
The catalog-item-repository-name is matched against the Bitbucket repository slug of the item.<br/>
169+
Returns 404 if no catalog item matches the provided slug.
170+
operationId: getCatalogItemBySlug
171+
parameters:
172+
- name: slug
173+
in: path
174+
description: >
175+
Composite slug with format `{project-key}_{catalog-item-repository-name}`.
176+
The separator is the first underscore; the repo name may contain additional underscores.
177+
Example: `myproject_my-component-repo`
178+
required: true
179+
schema:
180+
type: string
181+
example: 'myproject_my-component-repo'
182+
responses:
183+
"200":
184+
description: The CatalogItem.
185+
content:
186+
application/json:
187+
schema:
188+
$ref: '#/components/schemas/CatalogItem'
189+
"400":
190+
description: Invalid or malformed slug provided.
191+
content:
192+
application/json:
193+
schema:
194+
$ref: '#/components/schemas/RestErrorMessage'
195+
"401":
196+
description: Invalid client token on the request.
197+
content:
198+
application/json:
199+
schema:
200+
$ref: '#/components/schemas/RestErrorMessage'
201+
"403":
202+
description: Insufficient permissions for the client to access the resource.
203+
content:
204+
application/json:
205+
schema:
206+
$ref: '#/components/schemas/RestErrorMessage'
207+
"404":
208+
description: No CatalogItem associated to the provided slug.
209+
content:
210+
application/json:
211+
schema:
212+
$ref: '#/components/schemas/RestErrorMessage'
213+
"422":
214+
description: Invalid CatalogItem associated to the provided slug.
215+
content:
216+
application/json:
217+
schema:
218+
$ref: '#/components/schemas/RestErrorMessage'
219+
"500":
220+
description: Server error.
221+
content:
222+
application/json:
223+
schema:
224+
$ref: '#/components/schemas/RestErrorMessage'
165225
/catalog-items:
166226
get:
167227
tags:
@@ -291,12 +351,6 @@ paths:
291351
required: true
292352
schema:
293353
type: string
294-
- name: accessToken
295-
in: query
296-
description: access token for azure queries.
297-
required: true
298-
schema:
299-
type: string
300354
- name: sortByTitle
301355
in: query
302356
description: Sort the returned CatalogItems by title, either in ascending or descending order.
@@ -370,12 +424,6 @@ paths:
370424
required: true
371425
schema:
372426
type: string
373-
- name: accessToken
374-
in: query
375-
description: access token for azure queries.
376-
required: true
377-
schema:
378-
type: string
379427
responses:
380428
"200":
381429
description: The CatalogItem.
@@ -642,9 +690,9 @@ paths:
642690
put:
643691
tags:
644692
- ProvisionerActions
645-
summary: Notify provisioning Status Update
693+
summary: Create new project component
646694
description: >
647-
This endpoint receives provisioning status update notifications from AWX.
695+
This endpoint will create a new project component.
648696
operationId: notifyProvisioningStatusUpdate
649697
parameters:
650698
- name: project-key
@@ -678,6 +726,45 @@ paths:
678726
description: Insufficient permissions for the client to access the resource.
679727
"500":
680728
description: Server error.
729+
patch:
730+
tags:
731+
- ProvisionerActions
732+
summary: Update an existing project component
733+
description: >
734+
This endpoint receives provisioning status update notifications from AWX.
735+
operationId: notifyProvisioningStatusUpdatePartially
736+
parameters:
737+
- name: project-key
738+
in: path
739+
description: Project key of the provisioned component.
740+
required: true
741+
schema:
742+
type: string
743+
- name: status
744+
in: path
745+
description: Provisioning status for the component.
746+
required: true
747+
example: CREATING
748+
schema:
749+
type: string
750+
enum: [ CREATING, CREATED, FAILED, DELETING, UNKNOWN ]
751+
requestBody:
752+
required: true
753+
content:
754+
application/json:
755+
schema:
756+
$ref: '#/components/schemas/ProvisioningStatusUpdateRequest'
757+
responses:
758+
"200":
759+
description: Provisioning status update completed.
760+
"400":
761+
description: Bad request.
762+
"401":
763+
description: Invalid client token on the request.
764+
"403":
765+
description: Insufficient permissions for the client to access the resource.
766+
"500":
767+
description: Server error.
681768

682769
/provision/{project-key}:
683770
delete:
@@ -787,6 +874,12 @@ components:
787874
id:
788875
type: string
789876
example: 'aSdFam...yCg=='
877+
slug:
878+
type: string
879+
description: >
880+
Composite slug computed from the normalised Bitbucket project key and the repository slug of the item,
881+
in the format `{project-key}_{repo-name}`. Calculated at mapping time; not retrieved from Bitbucket.
882+
example: 'myproject_my-component-repo'
790883
path:
791884
type: string
792885
example: projects/SOMEPROJECT/repos/some-repo/raw/CatalogItem.yaml?at=refs/heads/master
@@ -836,6 +929,7 @@ components:
836929
- date
837930
example:
838931
id: aSdFam...yCg==
932+
slug: myproject_some-repo
839933
path: projects/SOMEPROJECT/repos/some-repo/raw/CatalogItem.yaml?at=refs/heads/master
840934
title: An item title
841935
shortDescription: This is a short description for the item
@@ -974,6 +1068,10 @@ components:
9741068
type: string
9751069
nullable: true
9761070
example: 'some hint for a workflow'
1071+
sendOnDeletion:
1072+
type: boolean
1073+
nullable: true
1074+
example: false
9771075
visible:
9781076
type: boolean
9791077
example: 'true'
@@ -1096,15 +1194,40 @@ components:
10961194
pattern: '^(?!\s*$).+' # reject whitespace-only
10971195
description: The componentId set by the user.
10981196
example: "any-component-id-from-backend"
1197+
10991198
catalogItemId:
11001199
type: string
11011200
description: The base64 encoded path for the catalogItem. It may include branch reference.
11021201
example: "cHJvamVjdHMvQ0FURVNUL3JlcG9zL3VzZXItYWN0aW9ucy1pdGVtL3Jhdy9DYXRhbG9nSXRlbS55YW1sP2F0PXJlZnMvaGVhZHMvbWFzdGVy"
1202+
11031203
componentUrl:
11041204
type: string
11051205
description: the repository url where the component was provisioned
11061206
example: "https://bitbucket.com/projects/DEVSTACK/repos/devstack-component-catalog"
11071207
nullable: true
1208+
1209+
parameters:
1210+
type: array
1211+
description: List of name/value string parameters.
1212+
items:
1213+
type: object
1214+
required:
1215+
- name
1216+
- value
1217+
properties:
1218+
name:
1219+
type: string
1220+
description: Parameter name
1221+
example: "environment"
1222+
values:
1223+
type: array
1224+
description: Parameter values
1225+
items:
1226+
type: string
1227+
example:
1228+
- "production"
1229+
- "staging"
1230+
11081231
ProvisioningDeleteRequest:
11091232
type: object
11101233
properties:
@@ -1113,4 +1236,26 @@ components:
11131236
minLength: 1 # disallows empty string ""
11141237
pattern: '^(?!\s*$).+' # reject whitespace-only
11151238
description: The componentId set by the user.
1116-
example: "any-component-id-from-backend"
1239+
example: "any-component-id-from-backend"
1240+
1241+
parameters:
1242+
type: array
1243+
description: List of name/value string parameters.
1244+
items:
1245+
type: object
1246+
required:
1247+
- name
1248+
- value
1249+
properties:
1250+
name:
1251+
type: string
1252+
description: Parameter name
1253+
example: "environment"
1254+
values:
1255+
type: array
1256+
description: Parameter values
1257+
items:
1258+
type: string
1259+
example:
1260+
- "production"
1261+
- "staging"

openapi-specs/projects-info-service-v1.0.0.yaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ paths:
3434
description: >
3535
This endpoint receives an azure token, and returns all the groups associated to the user.
3636
operationId: getAzureGroups
37-
parameters:
38-
- name: token
39-
in: header
40-
required: true
41-
schema:
42-
type: string
43-
description: Azure token used to get the groups.
4437
responses:
4538
"200":
4639
description: List of azure groups associated to the user.
@@ -77,13 +70,6 @@ paths:
7770
Get all the projects a user get access to. For that, first of all it will get all the azure groups associated to the user,
7871
and then it will get all the projects associated to those groups.
7972
operationId: getProjects
80-
parameters:
81-
- name: token
82-
in: header
83-
required: true
84-
schema:
85-
type: string
86-
description: Azure token used to get the groups.
8773
responses:
8874
"200":
8975
description: List of projects the user has access to.
@@ -120,12 +106,6 @@ paths:
120106
Get all project info and cluster for a given project key.
121107
operationId: getProjectClusters
122108
parameters:
123-
- name: token
124-
in: header
125-
required: true
126-
schema:
127-
type: string
128-
description: Azure token used to get the groups.
129109
- name: projectKey
130110
in: path
131111
required: true

src/app/app.component.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,22 @@ export class AppComponent implements OnInit, OnDestroy {
139139
// Apply optimistic UI, start with it and later apply validations after fetching projects to avoid empty parts
140140
this.projectPicker = {...this.projectPicker, label: 'Project: ', selected: currentProjectForUi.projectKey};
141141
}
142-
this.azureService.getAccessToken().then((accessToken: string) => {
143-
this.projectService.getUserProjects(accessToken).subscribe((projects: string[]) => {
144-
user.projects = projects;
145-
this.initializeNats(user);
146-
if (projects.length > 0) {
147-
const latestCurrentProject = this.projectService.getCurrentProject();
148-
if (latestCurrentProject != null && projects.includes(latestCurrentProject.projectKey)) {
149-
this.pickProject(latestCurrentProject.projectKey);
150-
this.projectPicker = {...this.projectPicker, label: 'Project: ', selected: latestCurrentProject.projectKey, options: projects};
151-
} else {
152-
this.pickProject(projects[0]);
153-
this.projectPicker = {...this.projectPicker, label: 'Project: ', selected: projects[0], options: projects};
154-
}
142+
this.projectService.getUserProjects().subscribe((projects: string[]) => {
143+
user.projects = projects;
144+
this.initializeNats(user);
145+
if (projects.length > 0) {
146+
const latestCurrentProject = this.projectService.getCurrentProject();
147+
if (latestCurrentProject != null && projects.includes(latestCurrentProject.projectKey)) {
148+
this.pickProject(latestCurrentProject.projectKey);
149+
this.projectPicker = {...this.projectPicker, label: 'Project: ', selected: latestCurrentProject.projectKey, options: projects};
155150
} else {
156-
this.pickProject(null);
157-
this.projectPicker = {...this.projectPicker, label: 'Select project', selected: undefined, options: [] };
151+
this.pickProject(projects[0]);
152+
this.projectPicker = {...this.projectPicker, label: 'Project: ', selected: projects[0], options: projects};
158153
}
159-
160-
});
154+
} else {
155+
this.pickProject(null);
156+
this.projectPicker = {...this.projectPicker, label: 'Select project', selected: undefined, options: [] };
157+
}
161158
});
162159
}
163160
});

0 commit comments

Comments
 (0)