srijeet0406 commented on code in PR #7480:
URL: https://github.com/apache/trafficcontrol/pull/7480#discussion_r1199323118
##########
experimental/traffic-portal/src/app/api/profile.service.ts:
##########
@@ -103,4 +124,64 @@ export class ProfileService extends APIService {
return
this.delete<ResponseProfile>(`profiles/${id}`).toPromise();
}
+ public async getParameters(idOrName: number | string):
Promise<ResponseParameter>;
+ public async getParameters(): Promise<Array<ResponseParameter>>;
+ /**
+ * Retrieves Parameters from the API.
+ *
+ * @param idOrName Specify either the integral, unique identifier
(number) of a specific Parameter to retrieve,
+ * or its name (string).
+ * @returns The requested Parameter(s).
+ */
+ public async getParameters(idOrName?: number | string):
Promise<Array<ResponseParameter> | ResponseParameter> {
+ const path = "parameters";
+ if (idOrName !== undefined) {
+ let params;
+ switch (typeof idOrName) {
+ case "number":
+ params = {id: idOrName};
+ break;
+ case "string":
+ params = {name: idOrName};
+ }
+ const r = await this.get<[ResponseParameter]>(path,
undefined, params).toPromise();
+ if (r.length !== 1) {
+ throw new Error(`Traffic Ops responded with
${r.length} Types by identifier ${idOrName}`);
Review Comment:
Niot sure how I could make it return two params with the same ID?
##########
experimental/traffic-portal/src/app/api/profile.service.ts:
##########
@@ -103,4 +124,64 @@ export class ProfileService extends APIService {
return
this.delete<ResponseProfile>(`profiles/${id}`).toPromise();
}
+ public async getParameters(idOrName: number | string):
Promise<ResponseParameter>;
+ public async getParameters(): Promise<Array<ResponseParameter>>;
+ /**
+ * Retrieves Parameters from the API.
+ *
+ * @param idOrName Specify either the integral, unique identifier
(number) of a specific Parameter to retrieve,
+ * or its name (string).
+ * @returns The requested Parameter(s).
+ */
+ public async getParameters(idOrName?: number | string):
Promise<Array<ResponseParameter> | ResponseParameter> {
+ const path = "parameters";
+ if (idOrName !== undefined) {
+ let params;
+ switch (typeof idOrName) {
+ case "number":
+ params = {id: idOrName};
+ break;
+ case "string":
+ params = {name: idOrName};
+ }
+ const r = await this.get<[ResponseParameter]>(path,
undefined, params).toPromise();
+ if (r.length !== 1) {
+ throw new Error(`Traffic Ops responded with
${r.length} Types by identifier ${idOrName}`);
Review Comment:
Not sure how I could make it return two params with the same ID?
--
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]