ocket8888 commented on code in PR #7243:
URL: https://github.com/apache/trafficcontrol/pull/7243#discussion_r1047784373
##########
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:
Casting to a `string` like this is unnecessary, the HTTP client will handle
things like that for you.
--
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]