zrhoffman commented on code in PR #7615:
URL: https://github.com/apache/trafficcontrol/pull/7615#discussion_r1273676562


##########
experimental/traffic-portal/src/app/api/testing/topology.service.ts:
##########
@@ -0,0 +1,130 @@
+/*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { Injectable } from "@angular/core";
+import {
+       RequestTopology,
+       ResponseTopology,
+       ResponseTopologyNode
+} from "trafficops-types";
+
+/**
+ * TopologyService expose API functionality relating to Topologies.
+ */
+@Injectable()
+export class TopologyService {
+       private readonly topologies: ResponseTopology[] = [
+               {
+                       description: "",
+                       lastUpdated: new Date(),
+                       name: "test",
+                       nodes: [
+                               {
+                                       cachegroup: "Edge",
+                                       parents: [1],
+                               },
+                               {
+                                       cachegroup: "Mid",
+                                       parents: [2],
+                               },
+                               {
+                                       cachegroup: "Origin",
+                                       parents: [],
+                               },
+                       ],
+               }
+       ];
+
+       /**
+        * Gets one or all Topologies from Traffic Ops
+        *
+        * @param name? The integral, unique identifier of a single Topology to 
be

Review Comment:
   > I think this is a valid JSDoc, but you don't need to put the `?` in the 
param name. It's not a linter error, so I'm fine with this if you want to keep 
it, but it's not done anywhere else, and the compiler keeps track of what is 
actually optional or not without that needing to be spelled out in the comment.
   
   `?` removed
   
   
   > Identifiers for Topologies are not integral.
   
   Removed *integral*



##########
experimental/traffic-portal/src/app/api/testing/topology.service.ts:
##########
@@ -0,0 +1,130 @@
+/*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { Injectable } from "@angular/core";
+import {
+       RequestTopology,
+       ResponseTopology,
+       ResponseTopologyNode
+} from "trafficops-types";
+
+/**
+ * TopologyService expose API functionality relating to Topologies.
+ */
+@Injectable()
+export class TopologyService {
+       private readonly topologies: ResponseTopology[] = [
+               {
+                       description: "",
+                       lastUpdated: new Date(),
+                       name: "test",
+                       nodes: [
+                               {
+                                       cachegroup: "Edge",
+                                       parents: [1],
+                               },
+                               {
+                                       cachegroup: "Mid",
+                                       parents: [2],
+                               },
+                               {
+                                       cachegroup: "Origin",
+                                       parents: [],
+                               },
+                       ],
+               }
+       ];
+
+       /**
+        * Gets one or all Topologies from Traffic Ops
+        *
+        * @param name? The integral, unique identifier of a single Topology to 
be
+        * returned
+        * @returns Either a Map of Topology names to full Topology objects, or 
a single Topology, depending on whether `id` was
+        *      passed.
+        * (In the event that `id` is passed but does not match any Topology, 
`null` will be emitted)
+        */
+       public async getTopologies(name?: string): 
Promise<Array<ResponseTopology> | ResponseTopology> {
+               if (name !== undefined) {
+                       const topology = this.topologies.find(t => t.name === 
name);
+                       if (!topology) {
+                               throw new Error(`no such Topology #${name}`);
+                       }
+                       return topology;
+               }
+               return this.topologies;
+       }
+
+       /**
+        * Deletes a Topology.
+        *
+        * @param topology The Topology to be deleted, or just its ID.

Review Comment:
   Changed to `name`



-- 
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: issues-unsubscr...@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to