kdamichie commented on code in PR #7243:
URL: https://github.com/apache/trafficcontrol/pull/7243#discussion_r1048724749
##########
experimental/traffic-portal/src/app/api/cache-group.service.ts:
##########
@@ -162,6 +162,77 @@ export class CacheGroupService extends APIService {
return
this.delete<ResponseDivision>(`divisions/${id}`).toPromise();
}
+ public async getRegions(): Promise<Array<ResponseRegion>>;
+ public async getRegions(nameOrID: string | number):
Promise<ResponseRegion>;
+
+ /**
+ * Gets an array of regions from Traffic Ops.
+ *
+ * @param nameOrID If given, returns only the Region with the given name
+ * (string) or ID (number).
+ * @returns An Array of Region objects - or a single Region object if
'nameOrID'
+ * was given.
+ */
+ public async getRegions(nameOrID?: string | number):
Promise<Array<ResponseRegion> | ResponseRegion> {
+ const path = "regions";
+ if(nameOrID) {
+ let params;
+ switch (typeof nameOrID) {
+ case "string":
+ params = {name: nameOrID};
+ break;
+ case "number":
+ params = {id: String(nameOrID)};
Review Comment:
Removing `string` casting breaks line 187 parameter: `params` with error:
```TS2345: Argument of type '{ name: string; } | { id: number; }' is not
assignable to parameter of type 'Record<string, string> | undefined'. Type '{
id: number; }' is not assignable to type 'Record<string, string>'. Property
'id' is incompatible with index signature. Type 'number' is not
assignable to type 'string'.```
Did you want to leave it or try to figure our a different fix?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]