ocket8888 commented on code in PR #7243:
URL: https://github.com/apache/trafficcontrol/pull/7243#discussion_r1048769222
##########
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:
Hm. Looks like I incorrectly typed the params argument as `Record<string,
string>`. It should be `@angular/common/http.HttpParams | Record<string, string
| number | boolean | ReadonlyArray<string | number | boolean>>`. You can fix
that if you want, but it could wind up being a very involved change given how
many places use it, but if you'd rather leave the cast for now that can be
fixed at a later date.
--
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]