ocket8888 commented on code in PR #7480:
URL: https://github.com/apache/trafficcontrol/pull/7480#discussion_r1204786709
##########
experimental/traffic-portal/src/app/api/testing/profile.service.ts:
##########
@@ -283,4 +283,45 @@ export class ProfileService {
this.parameters.push(t);
return t;
}
+
+ /**
+ * Replaces an existing Parameter with the provided new definition of a
+ * Parameter.
+ *
+ * @param parameter The full new definition of the Parameter being
+ * updated.
+ * @returns The updated Parameter
+ */
+ public async updateParameter(parameter: ResponseParameter):
Promise<ResponseParameter> {
+ const id = this.parameters.findIndex(d => d.id ===
parameter.id);
+ if (id === -1) {
+ throw new Error(`no such parameter: ${parameter.id}`);
+ }
+ this.parameters[id] = parameter;
+ return parameter;
+ }
+
+ /**
+ * Retrieves Profiles associated with a Parameter from the API.
+ *
+ * @param parameter Either a {@link ResponseParameter} or an integral,
unique identifier of a Parameter, for which the
+ * Profiles are to be retrieved.
+ * @returns The requested Profile(s).
+ */
+ public async getProfilesByParam(parameter: number| ResponseParameter):
Promise<Array<ResponseProfile>> {
+ const id = typeof parameter === "number" ? parameter :
parameter.id;
+ if (id === -1) {
+ throw new Error(`no such parameter: ${id}`);
+ }
+ const profiles = this.parameters[id].profiles;
Review Comment:
`this.parameters[id]` is not the Parameter with the ID `id`, it's the
Parameter at the `id`<sup>th</sup> position in the `this.parameters` array.
--
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]