This is an automated email from the ASF dual-hosted git repository.
zrhoffman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new b1d83a5d3c TPv2 lint fixes (#7937)
b1d83a5d3c is described below
commit b1d83a5d3c985af61e4918793799e3212e0ec880
Author: ocket8888 <[email protected]>
AuthorDate: Thu Feb 8 13:47:16 2024 -0700
TPv2 lint fixes (#7937)
* Update TPv2 to fix new linting errors (now that linter works)
I also made miscellaneous spelling/grammar fixes in JSDoc comment blocks.
* Remove the CoordinateService API Service
Its only method is already present on the CacheGroupService
* fix an API testing service method call signature mismatch with concrete
* Fix typo
* Add accessible keypress handlers to treeselect component
* npm audit fix
---
experimental/traffic-portal/package-lock.json | 13 ++
.../src/app/api/cache-group.service.ts | 98 +++++++-----
.../src/app/api/coordinate.service.spec.ts | 117 --------------
.../src/app/api/coordinate.service.ts | 85 -----------
experimental/traffic-portal/src/app/api/index.ts | 3 -
.../traffic-portal/src/app/api/origin.service.ts | 18 +--
.../traffic-portal/src/app/api/profile.service.ts | 43 ++++--
.../traffic-portal/src/app/api/server.service.ts | 29 +++-
.../src/app/api/testing/cache-group.service.ts | 168 ++++++++++++++-------
.../src/app/api/testing/cdn.service.ts | 21 ++-
.../src/app/api/testing/coordinate.service.ts | 68 ---------
.../app/api/testing/delivery-service.service.ts | 145 ++++++++++++++----
.../traffic-portal/src/app/api/testing/index.ts | 3 -
.../src/app/api/testing/origin.service.ts | 32 ++--
.../app/api/testing/physical-location.service.ts | 22 ++-
.../src/app/api/testing/profile.service.ts | 67 +++++---
.../src/app/api/testing/server.service.ts | 55 +++++--
.../src/app/api/testing/type.service.ts | 19 ++-
.../src/app/api/testing/user.service.ts | 19 ++-
.../traffic-portal/src/app/api/type.service.ts | 14 +-
.../deliveryservice/ds-card/ds-card.component.html | 2 +-
.../core/origins/detail/origin-detail.component.ts | 4 +-
.../shared/tree-select/tree-select.component.html | 4 +-
23 files changed, 546 insertions(+), 503 deletions(-)
diff --git a/experimental/traffic-portal/package-lock.json
b/experimental/traffic-portal/package-lock.json
index 0eef458c32..e737637804 100644
--- a/experimental/traffic-portal/package-lock.json
+++ b/experimental/traffic-portal/package-lock.json
@@ -13202,6 +13202,19 @@
"integrity":
"sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
"devOptional": true
},
+ "node_modules/fsevents": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+ "integrity":
"sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+ "hasInstallScript": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
"node_modules/function-bind": {
"version": "1.1.1",
"resolved":
"https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
diff --git a/experimental/traffic-portal/src/app/api/cache-group.service.ts
b/experimental/traffic-portal/src/app/api/cache-group.service.ts
index c0d538739b..f1a020dd36 100644
--- a/experimental/traffic-portal/src/app/api/cache-group.service.ts
+++ b/experimental/traffic-portal/src/app/api/cache-group.service.ts
@@ -228,16 +228,26 @@ export class CacheGroupService extends APIService {
return this.post<CacheGroupQueueResponse>(path,
request).toPromise();
}
+ /**
+ * Gets all Divisions from Traffic Ops.
+ *
+ * @returns The requested Divisions.
+ */
public async getDivisions(): Promise<Array<ResponseDivision>>;
+ /**
+ * Gets a single Division from Traffic Ops.
+ *
+ * @param nameOrID Either the name (string) or ID (number) of the single
+ * Division to be fetched.
+ * @returns The requested Division.
+ */
public async getDivisions(nameOrID: string | number):
Promise<ResponseDivision>;
-
/**
- * Gets an array of divisions from Traffic Ops.
+ * Gets a Division or Divisions from Traffic Ops.
*
* @param nameOrID If given, returns only the Division with the given
name
* (string) or ID (number).
- * @returns An Array of Division objects - or a single Division object
if 'nameOrID'
- * was given.
+ * @returns The requested Division or Divisions.
*/
public async getDivisions(nameOrID?: string | number):
Promise<Array<ResponseDivision> | ResponseDivision> {
const path = "divisions";
@@ -258,10 +268,10 @@ export class CacheGroupService extends APIService {
}
/**
- * Replaces the current definition of a division with the one given.
+ * Replaces the current definition of a Division with the one given.
*
- * @param division The new division.
- * @returns The updated division.
+ * @param division The new Division.
+ * @returns The updated Division.
*/
public async updateDivision(division: ResponseDivision):
Promise<ResponseDivision> {
const path = `divisions/${division.id}`;
@@ -279,26 +289,36 @@ export class CacheGroupService extends APIService {
}
/**
- * Deletes an existing division.
+ * Deletes an existing Division.
*
* @param division The Division to be deleted, or just its ID.
- * @returns The deleted division.
+ * @returns The deleted Division.
*/
public async deleteDivision(division: number | ResponseDivision):
Promise<ResponseDivision> {
const id = typeof(division) === "number" ? division :
division.id;
return
this.delete<ResponseDivision>(`divisions/${id}`).toPromise();
}
+ /**
+ * Gets all Regions from Traffic Ops.
+ *
+ * @returns The requested Regions.
+ */
public async getRegions(): Promise<Array<ResponseRegion>>;
+ /**
+ * Gets a single Region from Traffic Ops.
+ *
+ * @param nameOrID The name (string) or ID (number) of the single
Region to
+ * be fetched.
+ * @returns The requested Region.
+ */
public async getRegions(nameOrID: string | number):
Promise<ResponseRegion>;
-
/**
- * Gets an array of regions from Traffic Ops.
+ * Gets a Region or 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.
+ * @returns The requested Region or Regions.
*/
public async getRegions(nameOrID?: string | number):
Promise<Array<ResponseRegion> | ResponseRegion> {
const path = "regions";
@@ -318,10 +338,10 @@ export class CacheGroupService extends APIService {
}
/**
- * Replaces the current definition of a region with the one given.
+ * Replaces the current definition of a Region with the one given.
*
- * @param region The new region.
- * @returns The updated region.
+ * @param region The new Region.
+ * @returns The updated Region.
*/
public async updateRegion(region: ResponseRegion):
Promise<ResponseRegion> {
const path = `regions/${region.id}`;
@@ -329,7 +349,7 @@ export class CacheGroupService extends APIService {
}
/**
- * Creates a new region.
+ * Creates a new Region.
*
* @param region The region to create.
* @returns The created region.
@@ -339,26 +359,36 @@ export class CacheGroupService extends APIService {
}
/**
- * Deletes an existing region.
+ * Deletes an existing Region.
*
- * @param regionOrId Id of the region to delete.
- * @returns The deleted region.
+ * @param regionOrId The ID of the Region to delete.
+ * @returns The deleted Region.
*/
public async deleteRegion(regionOrId: number | ResponseRegion):
Promise<void> {
const id = typeof(regionOrId) === "number" ? regionOrId :
regionOrId.id;
await this.delete("regions", undefined, { id }).toPromise();
}
+ /**
+ * Gets all Coordinates from Traffic Ops.
+ *
+ * @returns The requested Coordinates.
+ */
public async getCoordinates(): Promise<Array<ResponseCoordinate>>;
+ /**
+ * Gets a single Coordinate from Traffic Ops.
+ *
+ * @param nameOrID The name (string) or ID (number) of the single
Coordinate
+ * to be fetched.
+ * @returns The requested Coordinate.
+ */
public async getCoordinates(nameOrID: string | number):
Promise<ResponseCoordinate>;
-
/**
- * Gets an array of coordinates from Traffic Ops.
+ * Gets a Coordinate or Coordinates from Traffic Ops.
*
* @param nameOrID If given, returns only the Coordinate with the given
name
* (string) or ID (number).
- * @returns An Array of Coordinate objects - or a single Coordinate
object if 'nameOrID'
- * was given.
+ * @returns The requested Coordinate or Coordinates.
*/
public async getCoordinates(nameOrID?: string | number):
Promise<Array<ResponseCoordinate> | ResponseCoordinate> {
const path = "coordinates";
@@ -378,30 +408,30 @@ export class CacheGroupService extends APIService {
}
/**
- * Replaces the current definition of a coordinate with the one given.
+ * Replaces the current definition of a Coordinate with the one given.
*
- * @param coordinate The new coordinate.
- * @returns The updated coordinate.
+ * @param coordinate The new Coordinate.
+ * @returns The updated Coordinate.
*/
public async updateCoordinate(coordinate: ResponseCoordinate):
Promise<ResponseCoordinate> {
return this.put<ResponseCoordinate>("coordinates", coordinate,
{ id: coordinate.id }).toPromise();
}
/**
- * Creates a new coordinate.
+ * Creates a new Coordinate.
*
- * @param coordinate The coordinate to create.
- * @returns The created coordinate.
+ * @param coordinate The Coordinate to create.
+ * @returns The created Coordinate.
*/
public async createCoordinate(coordinate: RequestCoordinate):
Promise<ResponseCoordinate> {
return this.post<ResponseCoordinate>("coordinates",
coordinate).toPromise();
}
/**
- * Deletes an existing coordinate.
+ * Deletes an existing Coordinate.
*
- * @param coordinateOrId Id of the coordinate to delete.
- * @returns The deleted coordinate.
+ * @param coordinateOrId The ID of the Coordinate to delete.
+ * @returns The deleted Coordinate.
*/
public async deleteCoordinate(coordinateOrId: number |
ResponseCoordinate): Promise<void> {
const id = typeof(coordinateOrId) === "number" ? coordinateOrId
: coordinateOrId.id;
@@ -425,7 +455,7 @@ export class CacheGroupService extends APIService {
/**
* Gets ASNs from Traffic Ops.
*
- * @param id If given, returns only the asn with the given ID.
+ * @param id If given, returns only the ASN with the given ID.
* @returns An Array of ASNs objects - or a single ASN object if `id`
* was given.
*/
diff --git a/experimental/traffic-portal/src/app/api/coordinate.service.spec.ts
b/experimental/traffic-portal/src/app/api/coordinate.service.spec.ts
deleted file mode 100644
index b0811ddb85..0000000000
--- a/experimental/traffic-portal/src/app/api/coordinate.service.spec.ts
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * @license Apache-2.0
- * 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 {
- HttpClientTestingModule,
- HttpTestingController,
-} from "@angular/common/http/testing";
-import { TestBed } from "@angular/core/testing";
-
-import { CoordinateService } from "./coordinate.service";
-
-describe("CoordinateService", () => {
- let service: CoordinateService;
- let httpTestingController: HttpTestingController;
- const coordinate = {
- id: 1,
- lastUpdated: new Date(),
- latitude: 1.0,
- longitude: -1.0,
- name: "test_coordinate",
- };
-
- beforeEach(() => {
- TestBed.configureTestingModule({
- imports: [HttpClientTestingModule],
- providers: [CoordinateService],
- });
- service = TestBed.inject(CoordinateService);
- httpTestingController = TestBed.inject(HttpTestingController);
- });
-
- it("should be created", () => {
- expect(service).toBeTruthy();
- });
-
- it("gets multiple Coordinates", async () => {
- const responseP = service.getCoordinates();
- const req = httpTestingController.expectOne(
- `/api/${service.apiVersion}/coordinates`
- );
- expect(req.request.method).toBe("GET");
- expect(req.request.params.keys().length).toBe(0);
- req.flush({ response: [coordinate] });
- await expectAsync(responseP).toBeResolvedTo([coordinate]);
- });
-
- it("gets a single Coordinate by ID", async () => {
- const responseP = service.getCoordinates(coordinate.id);
- const req = httpTestingController.expectOne(
- (r) => r.url ===
`/api/${service.apiVersion}/coordinates`
- );
- expect(req.request.method).toBe("GET");
- expect(req.request.params.keys().length).toBe(1);
-
expect(req.request.params.get("id")).toBe(String(coordinate.id));
- req.flush({ response: [coordinate] });
- await expectAsync(responseP).toBeResolvedTo(coordinate);
- });
-
- it("gets a single Coordinate by name", async () => {
- const responseP = service.getCoordinates(coordinate.name);
- const req = httpTestingController.expectOne(
- (r) => r.url ===
`/api/${service.apiVersion}/coordinates`
- );
- expect(req.request.method).toBe("GET");
- expect(req.request.params.keys().length).toBe(1);
- expect(req.request.params.get("name")).toBe(coordinate.name);
- req.flush({ response: [coordinate] });
- await expectAsync(responseP).toBeResolvedTo(coordinate);
- });
-
- it("sends requests for multiple coordinates by ID", async () => {
- const responseParams = service.getCoordinates(coordinate.id);
- const req = httpTestingController.expectOne(
- (r) => r.url ===
`/api/${service.apiVersion}/coordinates`
- );
- expect(req.request.method).toBe("GET");
- expect(req.request.params.keys().length).toBe(1);
-
expect(req.request.params.get("id")).toBe(String(coordinate.id));
- const data = {
- response: [
- {
- id: 1,
- lastUpdated: new Date(),
- latitude: 1.0,
- longitude: -1.0,
- name: "test_coordinate1",
- },
- {
- id: 1,
- lastUpdated: new Date(),
- latitude: 1.0,
- longitude: -1.0,
- name: "test_coordinate2",
- },
- ],
- };
- req.flush(data);
- await expectAsync(responseParams).toBeRejectedWithError(
- `Traffic Ops responded with 2 Coordinates by identifier
${coordinate.id}`
- );
- });
-
- afterEach(() => {
- httpTestingController.verify();
- });
-});
diff --git a/experimental/traffic-portal/src/app/api/coordinate.service.ts
b/experimental/traffic-portal/src/app/api/coordinate.service.ts
deleted file mode 100644
index 6d9d89ddf7..0000000000
--- a/experimental/traffic-portal/src/app/api/coordinate.service.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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 { HttpClient } from "@angular/common/http";
-import { Injectable } from "@angular/core";
-import type { ResponseCoordinate } from "trafficops-types";
-
-import { APIService } from "./base-api.service";
-
-/**
- * CoordinateService exposes API functionality relating to Coordinates.
- */
-@Injectable()
-export class CoordinateService extends APIService {
- /**
- * Gets a specific Coordinate from Traffic Ops.
- *
- * @param idOrName Either the integral, unique identifier (number) or
name
- * (string) of the Coordinate to be returned.
- * @returns The requested Coordinate.
- */
- public async getCoordinates(
- idOrName: number | string
- ): Promise<ResponseCoordinate>;
- /**
- * Gets Coordinates from Traffic Ops.
- *
- * @returns An Array of all Coordinates from Traffic Ops.
- */
- public async getCoordinates(): Promise<Array<ResponseCoordinate>>;
-
- /**
- * Gets one or all Coordinates from Traffic Ops.
- *
- * @param idOrName Optionally the integral, unique identifier (number)
or
- * name (string) of a single Coordinate to be returned.
- * @returns The requested Coordinate(s).
- */
- public async getCoordinates(
- idOrName?: number | string
- ): Promise<ResponseCoordinate | Array<ResponseCoordinate>> {
- const path = "coordinates";
- if (idOrName !== undefined) {
- let params;
- switch (typeof idOrName) {
- case "string":
- params = { name: idOrName };
- break;
- case "number":
- params = { id: idOrName };
- }
- const r = await this.get<[ResponseCoordinate]>(
- path,
- undefined,
- params
- ).toPromise();
- if (r.length !== 1) {
- throw new Error(
- `Traffic Ops responded with ${r.length}
Coordinates by identifier ${idOrName}`
- );
- }
- return r[0];
- }
- return this.get<Array<ResponseCoordinate>>(path).toPromise();
- }
-
- /**
- * Injects the Angular HTTP client service into the parent constructor.
- *
- * @param http The Angular HTTP client service.
- */
- constructor(http: HttpClient) {
- super(http);
- }
-}
diff --git a/experimental/traffic-portal/src/app/api/index.ts
b/experimental/traffic-portal/src/app/api/index.ts
index 7de4187ab3..19e41a0d6e 100644
--- a/experimental/traffic-portal/src/app/api/index.ts
+++ b/experimental/traffic-portal/src/app/api/index.ts
@@ -20,7 +20,6 @@ import { ChangeLogsService } from
"src/app/api/change-logs.service";
import { CacheGroupService } from "./cache-group.service";
import { CDNService } from "./cdn.service";
-import { CoordinateService } from "./coordinate.service";
import { DeliveryServiceService } from "./delivery-service.service";
import { InvalidationJobService } from "./invalidation-job.service";
import { MiscAPIsService } from "./misc-apis.service";
@@ -45,7 +44,6 @@ export * from "./topology.service";
export * from "./type.service";
export * from "./user.service";
export * from "./origin.service";
-export * from "./coordinate.service";
/**
* The API Module contains all logic used to access the Traffic Ops API.
@@ -69,7 +67,6 @@ export * from "./coordinate.service";
TypeService,
UserService,
OriginService,
- CoordinateService,
]
})
export class APIModule { }
diff --git a/experimental/traffic-portal/src/app/api/origin.service.ts
b/experimental/traffic-portal/src/app/api/origin.service.ts
index 50b74a9284..d38142253f 100644
--- a/experimental/traffic-portal/src/app/api/origin.service.ts
+++ b/experimental/traffic-portal/src/app/api/origin.service.ts
@@ -74,10 +74,10 @@ export class OriginService extends APIService {
}
/**
- * Deletes an existing origin.
+ * Deletes an existing Origin.
*
- * @param originOrId Id of the origin to delete.
- * @returns The deleted origin.
+ * @param originOrId The ID of the Origin to delete.
+ * @returns The deleted Origin.
*/
public async deleteOrigin(
originOrId: number | RequestOriginResponse
@@ -87,10 +87,10 @@ export class OriginService extends APIService {
}
/**
- * Creates a new origin.
+ * Creates a new Origin.
*
- * @param origin The origin to create.
- * @returns The created origin.
+ * @param origin The Origin to create.
+ * @returns The created Origin.
*/
public async createOrigin(
origin: RequestOrigin
@@ -99,10 +99,10 @@ export class OriginService extends APIService {
}
/**
- * Replaces the current definition of an origin with the one given.
+ * Replaces the current definition of an Origin with the one given.
*
- * @param origin The new origin.
- * @returns The updated origin.
+ * @param origin The new Origin.
+ * @returns The updated Origin.
*/
public async updateOrigin(
origin: RequestOriginResponse
diff --git a/experimental/traffic-portal/src/app/api/profile.service.ts
b/experimental/traffic-portal/src/app/api/profile.service.ts
index 623592a380..2ecf9eb0c3 100644
--- a/experimental/traffic-portal/src/app/api/profile.service.ts
+++ b/experimental/traffic-portal/src/app/api/profile.service.ts
@@ -132,21 +132,34 @@ export class ProfileService extends APIService {
}
/**
- * Import profile
+ * Imports a Profile along with all its associated Parameters.
*
- * @param importJSON JSON object for import.
- * @returns profile response for imported object.
+ * @param importJSON The specification of the Profile to be
imported/created.
+ * @returns The created Profile.
*/
public async importProfile(importJSON: ProfileImport):
Promise<ProfileImportResponse>{
return this.post<ProfileImportResponse>("profiles/import",
importJSON).toPromise();
}
- public async getParameters(id: number): Promise<ResponseParameter>;
+ /**
+ * Retrieves all Parameters from Traffic Ops.
+ *
+ * @returns The requested Parameters.
+ */
public async getParameters(): Promise<Array<ResponseParameter>>;
/**
- * Retrieves Parameters from the API.
+ * Retrieves a single Parameter from Traffic Ops.
+ *
+ * @param id The integral, unique identifier of the specific Parameter
to
+ * retrieve.
+ * @returns The requested Parameter(s).
+ */
+ public async getParameters(id: number): Promise<ResponseParameter>;
+ /**
+ * Retrieves a Parameter or Parameters from the API.
*
- * @param id Specify either the integral, unique identifier (number) of
a specific Parameter to retrieve.
+ * @param id If given, only the Parameter with this integral, unique
+ * identifier will be returned.
* @returns The requested Parameter(s).
*/
public async getParameters(id?: number):
Promise<Array<ResponseParameter> | ResponseParameter> {
@@ -163,10 +176,10 @@ export class ProfileService extends APIService {
}
/**
- * Deletes an existing parameter.
+ * Deletes an existing Parameter.
*
- * @param typeOrId Id of the parameter to delete.
- * @returns The deleted parameter.
+ * @param typeOrId The ID of the Parameter to delete.
+ * @returns The deleted Parameter.
*/
public async deleteParameter(typeOrId: number | ResponseParameter):
Promise<void> {
const id = typeof(typeOrId) === "number" ? typeOrId :
typeOrId.id;
@@ -174,20 +187,20 @@ export class ProfileService extends APIService {
}
/**
- * Creates a new parameter.
+ * Creates a new Parameter.
*
- * @param parameter The parameter to create.
- * @returns The created parameter.
+ * @param parameter The Parameter to create.
+ * @returns The created Parameter.
*/
public async createParameter(parameter: RequestParameter):
Promise<ResponseParameter> {
return this.post<ResponseParameter>("parameters",
parameter).toPromise();
}
/**
- * Replaces the current definition of a parameter with the one given.
+ * Replaces the current definition of a Parameter with the one given.
*
- * @param parameter The new parameter.
- * @returns The updated parameter.
+ * @param parameter The new Parameter.
+ * @returns The updated Parameter.
*/
public async updateParameter(parameter: ResponseParameter):
Promise<ResponseParameter> {
const path = `parameters/${parameter.id}`;
diff --git a/experimental/traffic-portal/src/app/api/server.service.ts
b/experimental/traffic-portal/src/app/api/server.service.ts
index be5c66a069..4061c95074 100644
--- a/experimental/traffic-portal/src/app/api/server.service.ts
+++ b/experimental/traffic-portal/src/app/api/server.service.ts
@@ -43,6 +43,12 @@ export class ServerService extends APIService {
super(http);
}
+ /**
+ * Retrieves servers from the API.
+ *
+ * @returns The requested servers.
+ */
+ public async getServers(): Promise<Array<ResponseServer>>;
/**
* Retrieves a single server from the API.
*
@@ -55,12 +61,6 @@ export class ServerService extends APIService {
* error.
*/
public async getServers(idOrName: number | string):
Promise<ResponseServer>;
- /**
- * Retrieves servers from the API.
- *
- * @returns The requested servers.
- */
- public async getServers(): Promise<Array<ResponseServer>>;
/**
* Retrieves servers from the API.
*
@@ -129,13 +129,26 @@ export class ServerService extends APIService {
return this.put<ResponseServer>(`servers/${id}`,
body).toPromise();
}
+ /**
+ * Fetches server "check" stats from Traffic Ops.
+ *
+ * @returns All Serverchecks Traffic Ops has.
+ */
public async getServerChecks(): Promise<Servercheck[]>;
+ /**
+ * Fetches a server's "check" stats from Traffic Ops.
+ *
+ * @param id The ID of the server whose "checks" will be returned.
+ * @returns The Servercheck for the server identified by `id`.
+ */
public async getServerChecks(id: number): Promise<Servercheck>;
/**
* Fetches server "check" stats from Traffic Ops.
*
- * @param id If given, will return only the checks for the server with
that ID.
- * @todo Ideally this filter would be implemented server-side; the data
set gets huge.
+ * @param id If given, will return only the checks for the server with
that
+ * ID.
+ * @todo Ideally this filter would be implemented server-side; the data
set
+ * gets huge.
* @returns Serverchecks - or a single Servercheck if ID was given.
*/
public async getServerChecks(id?: number): Promise<Servercheck |
Servercheck[]> {
diff --git
a/experimental/traffic-portal/src/app/api/testing/cache-group.service.ts
b/experimental/traffic-portal/src/app/api/testing/cache-group.service.ts
index fbe62ee514..d5627dc398 100644
--- a/experimental/traffic-portal/src/app/api/testing/cache-group.service.ts
+++ b/experimental/traffic-portal/src/app/api/testing/cache-group.service.ts
@@ -194,15 +194,31 @@ export class CacheGroupService {
constructor(private readonly servers: ServerService) {}
- public async getCacheGroups(idOrName: number | string):
Promise<ResponseCacheGroup>;
+ /**
+ * Gets all Cache Groups.
+ *
+ * @returns All stored Cache Groups.
+ */
public async getCacheGroups(): Promise<Array<ResponseCacheGroup>>;
/**
- * Gets one or all CDNs from Traffic Ops
+ * Gets a single Cache Group.
+ *
+ * @param idOrName Either the name or integral, unique identifier of the
+ * single Cache Group to be returned.
+ * @returns The requested Cache Group.
+ * @throws {Error} In the event that `idOrName` is passed but does not
match
+ * any CacheGroup.
+ */
+ public async getCacheGroups(idOrName: number | string):
Promise<ResponseCacheGroup>;
+ /**
+ * Gets one or all Cache Groups.
*
- * @param idOrName Optionally either the name or integral, unique
identifier of a single Cache Group to be returned.
- * @returns Either an Array of CacheGroup objects, or a single
CacheGroup, depending on whether
- * `idOrName` was passed.
- * @throws {Error} In the event that `idOrName` is passed but does not
match any CacheGroup.
+ * @param idOrName Optionally either the name or integral, unique
identifier
+ * of a single Cache Group to be returned.
+ * @returns Either all stored Cache Groups, or a single Cache Group,
+ * depending on whether `idOrName` was passed.
+ * @throws {Error} In the event that `idOrName` is passed but does not
match
+ * any CacheGroup.
*/
public async getCacheGroups(idOrName?: number | string):
Promise<Array<ResponseCacheGroup> | ResponseCacheGroup> {
if (idOrName !== undefined) {
@@ -456,16 +472,27 @@ export class CacheGroupService {
serverNames,
};
}
+
+ /**
+ * Gets all Divisions.
+ *
+ * @returns The requested Divisions.
+ */
public async getDivisions(): Promise<Array<ResponseDivision>>;
+ /**
+ * Gets a single Division.
+ *
+ * @param nameOrID Either the name (string) or ID (number) of the single
+ * Division to be returned.
+ * @returns The requested Division.
+ */
public async getDivisions(nameOrID: string | number):
Promise<ResponseDivision>;
-
/**
- * Gets an array of divisions from Traffic Ops.
+ * Gets a Division or Divisions.
*
- * @param nameOrID If given, returns only the ResponseDivision with the
given name
+ * @param nameOrID If given, returns only the Division with the given
name
* (string) or ID (number).
- * @returns An Array of ResponseDivision objects - or a single
ResponseDivision object if 'nameOrID'
- * was given.
+ * @returns The requested Division or Divisions.
*/
public async getDivisions(nameOrID?: string | number):
Promise<Array<ResponseDivision> | ResponseDivision> {
if(nameOrID) {
@@ -486,10 +513,10 @@ export class CacheGroupService {
}
/**
- * Replaces the current definition of a division with the one given.
+ * Replaces the current definition of a Division with the one given.
*
- * @param division The new division.
- * @returns The updated division.
+ * @param division The new Division.
+ * @returns The updated Division.
*/
public async updateDivision(division: ResponseDivision):
Promise<ResponseDivision> {
const id = this.divisions.findIndex(d => d.id === division.id);
@@ -501,10 +528,10 @@ export class CacheGroupService {
}
/**
- * Creates a new division.
+ * Creates a new Division.
*
- * @param division The division to create.
- * @returns The created division.
+ * @param division The Division to create.
+ * @returns The created Division.
*/
public async createDivision(division: RequestDivision):
Promise<ResponseDivision> {
const div = {
@@ -517,10 +544,10 @@ export class CacheGroupService {
}
/**
- * Deletes an existing division.
+ * Deletes an existing Division.
*
- * @param id Id of the division to delete.
- * @returns The deleted division.
+ * @param id Id of the Division to delete.
+ * @returns The deleted Division.
*/
public async deleteDivision(id: number): Promise<ResponseDivision> {
const index = this.divisions.findIndex(d => d.id === id);
@@ -530,16 +557,26 @@ export class CacheGroupService {
return this.divisions.splice(index, 1)[0];
}
+ /**
+ * Gets all Regions.
+ *
+ * @returns The requested Regions.
+ */
public async getRegions(): Promise<Array<ResponseRegion>>;
+ /**
+ * Gets a single Region.
+ *
+ * @param nameOrID The name (string) or ID (number) of the single
Region to
+ * be returned.
+ * @returns The requested Region.
+ */
public async getRegions(nameOrID: string | number):
Promise<ResponseRegion>;
-
/**
- * Gets an array of regions from Traffic Ops.
+ * Gets a Region or Regions.
*
- * @param nameOrID If given, returns only the ResponseRegion with the
given name
+ * @param nameOrID If given, returns only the Region with the given name
* (string) or ID (number).
- * @returns An Array of ResponseRegion objects - or a single
ResponseRegion object if 'nameOrID'
- * was given.
+ * @returns The requested Region or Regions.
*/
public async getRegions(nameOrID?: string | number):
Promise<Array<ResponseRegion> | ResponseRegion> {
if(nameOrID) {
@@ -560,10 +597,10 @@ export class CacheGroupService {
}
/**
- * Replaces the current definition of a region with the one given.
+ * Replaces the current definition of a Region with the one given.
*
- * @param region The new region.
- * @returns The updated region.
+ * @param region The new Region.
+ * @returns The updated Region.
*/
public async updateRegion(region: ResponseRegion):
Promise<ResponseRegion> {
const id = this.regions.findIndex(d => d.id === region.id);
@@ -575,10 +612,10 @@ export class CacheGroupService {
}
/**
- * Creates a new region.
+ * Creates a new Region.
*
- * @param region The region to create.
- * @returns The created region.
+ * @param region The Region to create.
+ * @returns The created Region.
*/
public async createRegion(region: RequestRegion):
Promise<ResponseRegion> {
const reg = {
@@ -592,10 +629,10 @@ export class CacheGroupService {
}
/**
- * Deletes an existing region.
+ * Deletes an existing Region.
*
- * @param id Id of the region to delete.
- * @returns The deleted region.
+ * @param id Id of the Region to delete.
+ * @returns The deleted Region.
*/
public async deleteRegion(id: number | ResponseRegion):
Promise<ResponseRegion> {
const index = this.regions.findIndex(d => d.id === id);
@@ -604,16 +641,27 @@ export class CacheGroupService {
}
return this.regions.splice(index, 1)[0];
}
+
+ /**
+ * Gets all Coordinates from Traffic Ops.
+ *
+ * @returns The requested Coordinates.
+ */
public async getCoordinates(): Promise<Array<ResponseCoordinate>>;
+ /**
+ * Gets a single Coordinate from Traffic Ops.
+ *
+ * @param nameOrID The name (string) or ID (number) of the single
Coordinate
+ * to be fetched.
+ * @returns The requested Coordinate.
+ */
public async getCoordinates(nameOrID: string | number):
Promise<ResponseCoordinate>;
-
/**
- * Gets an array of coordinates from Traffic Ops.
+ * Gets a Coordinate or Coordinates from Traffic Ops.
*
- * @param nameOrID If given, returns only the ResponseCoordinate with
the given name
+ * @param nameOrID If given, returns only the Coordinate with the given
name
* (string) or ID (number).
- * @returns An Array of ResponseCoordinate objects - or a single
ResponseCoordinate object if 'nameOrID'
- * was given.
+ * @returns The requested Coordinate or Coordinates.
*/
public async getCoordinates(nameOrID?: string | number):
Promise<Array<ResponseCoordinate> | ResponseCoordinate> {
if(nameOrID) {
@@ -634,10 +682,10 @@ export class CacheGroupService {
}
/**
- * Replaces the current definition of a coordinate with the one given.
+ * Replaces the current definition of a Coordinate with the one given.
*
- * @param coordinate The new coordinate.
- * @returns The updated coordinate.
+ * @param coordinate The new Coordinate.
+ * @returns The updated Coordinate.
*/
public async updateCoordinate(coordinate: ResponseCoordinate):
Promise<ResponseCoordinate> {
const id = this.coordinates.findIndex(c => c.id ===
coordinate.id);
@@ -649,10 +697,10 @@ export class CacheGroupService {
}
/**
- * Creates a new coordinate.
+ * Creates a new Coordinate.
*
- * @param coordinate The coordinate to create.
- * @returns The created coordinate.
+ * @param coordinate The Coordinate to create.
+ * @returns The created Coordinate.
*/
public async createCoordinate(coordinate: RequestCoordinate):
Promise<ResponseCoordinate> {
const crd = {
@@ -665,10 +713,10 @@ export class CacheGroupService {
}
/**
- * Deletes an existing coordinate.
+ * Deletes an existing Coordinate.
*
- * @param id Id of the coordinate to delete.
- * @returns The deleted coordinate.
+ * @param id Id of the Coordinate to delete.
+ * @returns The deleted Coordinate.
*/
public async deleteCoordinate(id: number): Promise<ResponseCoordinate> {
const index = this.coordinates.findIndex(c => c.id === id);
@@ -678,14 +726,25 @@ export class CacheGroupService {
return this.coordinates.splice(index, 1)[0];
}
+ /**
+ * Gets all ASNs.
+ *
+ * @returns All stored ASNs.
+ */
public async getASNs(): Promise<Array<ResponseASN>>;
+ /**
+ * Gets a single ASN.
+ *
+ * @param id The ID of the ASN to fetch.
+ * @returns The ASN with the given ID.
+ */
public async getASNs(id: number): Promise<ResponseASN>;
/**
- * Gets an array of ASNs from Traffic Ops.
+ * Gets all ASNs.
*
- * @param id If given, returns only the asn with the given id (number).
- * @returns An Array of ASNs objects - or a single ASN object if 'id'
+ * @param id If given, returns only the ASN with the given ID.
+ * @returns An Array of ASNs objects - or a single ASN object if `id`
* was given.
*/
public async getASNs(id?: number): Promise<Array<ResponseASN> |
ResponseASN> {
@@ -733,16 +792,15 @@ export class CacheGroupService {
}
/**
- * Deletes an existing asn.
+ * Deletes an existing ASN.
*
* @param asn The ASN to be deleted or ID of the ASN to delete..
- * @returns The deleted asn.
*/
- public async deleteASN(asn: ResponseASN | number): Promise<ResponseASN>
{
+ public async deleteASN(asn: ResponseASN | number): Promise<void> {
const index = this.asns.findIndex(a => a.asn === asn);
if (index === -1) {
throw new Error(`no such asn: ${asn}`);
}
- return this.asns.splice(index, 1)[0];
+ this.asns.splice(index, 1);
}
}
diff --git a/experimental/traffic-portal/src/app/api/testing/cdn.service.ts
b/experimental/traffic-portal/src/app/api/testing/cdn.service.ts
index a93c5cc947..66c0eb3534 100644
--- a/experimental/traffic-portal/src/app/api/testing/cdn.service.ts
+++ b/experimental/traffic-portal/src/app/api/testing/cdn.service.ts
@@ -39,15 +39,26 @@ export class CDNService {
}
];
- public async getCDNs(id: number): Promise<ResponseCDN>;
+ /**
+ * Gets all CDNs.
+ *
+ * @returns All CDNs.
+ */
public async getCDNs(): Promise<Array<ResponseCDN>>;
/**
- * Gets one or all CDNs from Traffic Ops
+ * Gets a specific CDN.
+ *
+ * @param id The integral, unique identifier of the single CDN to be
+ * returned.
+ * @returns The requested CDN.
+ */
+ public async getCDNs(id: number): Promise<ResponseCDN>;
+ /**
+ * Gets one or all CDNs.
*
- * @param id The integral, unique identifier of a single CDN to be
returned
- * @returns Either a Map of CDN names to full CDN objects, or a single
CDN, depending on whether `id` was
+ * @param id The integral, unique identifier of a single CDN to be
returned.
+ * @returns Either all CDNs or a single CDN, depending on whether `id`
was
* passed.
- * (In the event that `id` is passed but does not match any CDN, `null`
will be emitted)
*/
public async getCDNs(id?: number): Promise<Array<ResponseCDN> |
ResponseCDN> {
if (id !== undefined) {
diff --git
a/experimental/traffic-portal/src/app/api/testing/coordinate.service.ts
b/experimental/traffic-portal/src/app/api/testing/coordinate.service.ts
deleted file mode 100644
index a4a0f49759..0000000000
--- a/experimental/traffic-portal/src/app/api/testing/coordinate.service.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 type { ResponseCoordinate } from "trafficops-types";
-
-/**
- * CoordinateService exposes API functionality relating to Coordinates.
- */
-@Injectable()
-export class CoordinateService {
- private readonly coordinates: Array<ResponseCoordinate> = [
- {
- id: 1,
- lastUpdated: new Date(),
- latitude: 1.0,
- longitude: -1.0,
- name: "test_coordinate",
- },
- ];
-
- public async getCoordinates(): Promise<Array<ResponseCoordinate>>;
- public async getCoordinates(
- nameOrID: string | number
- ): Promise<ResponseCoordinate>;
-
- /**
- * Gets one or all Coordinates from Traffic Ops.
- *
- * @param nameOrID If given, returns only the ResponseCoordinate with
the given name
- * (string) or ID (number).
- * @returns An Array of ResponseCoordinate objects - or a single
ResponseCoordinate object if 'nameOrID'
- * was given.
- */
- public async getCoordinates(
- nameOrID?: string | number
- ): Promise<Array<ResponseCoordinate> | ResponseCoordinate> {
- if (nameOrID) {
- let coordinate;
- switch (typeof nameOrID) {
- case "string":
- coordinate = this.coordinates.find(
- (d) => d.name === nameOrID
- );
- break;
- case "number":
- coordinate = this.coordinates.find(
- (d) => d.id === nameOrID
- );
- }
- if (!coordinate) {
- throw new Error(`no such Coordinate:
${nameOrID}`);
- }
- return coordinate;
- }
- return this.coordinates;
- }
-}
diff --git
a/experimental/traffic-portal/src/app/api/testing/delivery-service.service.ts
b/experimental/traffic-portal/src/app/api/testing/delivery-service.service.ts
index cee43c5219..5be6ccac37 100644
---
a/experimental/traffic-portal/src/app/api/testing/delivery-service.service.ts
+++
b/experimental/traffic-portal/src/app/api/testing/delivery-service.service.ts
@@ -196,14 +196,26 @@ export class DeliveryServiceService {
return [];
}
- public async getDeliveryServices(id: string | number):
Promise<ResponseDeliveryService>;
+ /**
+ * Gets all Delivery Services.
+ *
+ * @returns All Delivery Services (visible to the user's Tenant).
+ */
public async getDeliveryServices():
Promise<Array<ResponseDeliveryService>>;
/**
- * Gets a list of all visible Delivery Services
+ * Gets a specific Delivery Service.
*
- * @param id A unique identifier for a Delivery Service - either a
numeric id or an "xml_id"
- * @throws TypeError if ``id`` is not a proper type
- * @returns An array of `DeliveryService` objects.
+ * @param id A unique identifier for the desired Delivery Service -
either
+ * its numeric id or its "xml_id".
+ * @returns The requested Delivery Service.
+ */
+ public async getDeliveryServices(id: string | number):
Promise<ResponseDeliveryService>;
+ /**
+ * Gets one or all Delivery Services.
+ *
+ * @param id If given, only the Delivery Service with this ID (number)
or
+ * "xml_id" (string) will be returned.
+ * @returns The requested Delivery Service(s).
*/
public async getDeliveryServices(id?: string | number):
Promise<ResponseDeliveryService[] | ResponseDeliveryService> {
if (id !== undefined) {
@@ -374,29 +386,84 @@ export class DeliveryServiceService {
};
}
- public async getDSKBPS(d: string, s: Date, e: Date, i: string, u:
boolean, dataOnly: true): Promise<Array<DataPoint>>;
- public async getDSKBPS(d: string, start: Date, end: Date, interval:
string, useMids: boolean, dataOnly?: false): Promise<DataResponse>;
/**
- * Retrieves Delivery Service throughput statistics for a given time
period, averaged over a given
- * interval.
+ * Retrieves Delivery Service throughput statistics for a given time
period,
+ * averaged over a given interval.
+ *
+ * @param d The Delivery Service for which stats will be returned or
just
+ * its "xml_id".
+ * @param start A date/time from which to start data collection.
+ * @param end A date/time at which to end data collection.
+ * @param interval A unit-suffixed interval over which data will be
+ * "binned".
+ * @param useMids If true, the returned data will be for mid-tier
caching
+ * servers rather than edge-tier. Implementation detail: in the testing
+ * service, this has absolutely no bearing on what is returned.
+ * @param dataOnly If given and false (which is also the default value)
+ * explicitly specifies that the entire data response should be
returned,
+ * and not just the data series itself.
+ * @returns A response with some randomly generated data.
+ */
+ public async getDSKBPS(
+ d: ResponseDeliveryService | string,
+ start: Date,
+ end: Date,
+ interval: string,
+ useMids: boolean,
+ dataOnly?: false
+ ): Promise<DataResponse>;
+ /**
+ * Retrieves Delivery Service throughput statistics for a given time
period,
+ * averaged over a given interval.
+ *
+ * @param d The Delivery Service for which stats will be returned or
just
+ * its "xml_id".
+ * @param start A date/time from which to start data collection.
+ * @param end A date/time at which to end data collection.
+ * @param interval A unit-suffixed interval over which data will be
+ * "binned".
+ * @param useMids If true, the returned data will be for mid-tier
caching
+ * servers rather than edge-tier. Implementation detail: in the testing
+ * service, this has absolutely no bearing on what is returned.
+ * @param dataOnly Only returns the data series, not any supplementing
meta
+ * info found in the API response.
+ * @returns An Array of datapoint Arrays (length 2 containing a date
string
+ * and data value).
+ */
+ public async getDSKBPS(
+ d: ResponseDeliveryService | string,
+ start: Date,
+ end: Date,
+ interval: string,
+ useMids: boolean,
+ dataOnly: true
+ ): Promise<Array<DataPoint>>;
+ /**
+ * Retrieves Delivery Service throughput statistics for a given time
period,
+ * averaged over a given interval.
*
- * @param d The `xml_id` of a Delivery Service
- * @param start A date/time from which to start data collection
- * @param end A date/time at which to end data collection
- * @param interval A unit-suffixed interval over which data will be
"binned"
- * @param _ Unuzed - kept for compatibility with the "concrete" service.
- * @param dataOnly Only returns the data series, not any supplementing
meta info found in the API response
- * @returns An Array of datapoint Arrays (length 2 containing a date
string and data value)
+ * @param d The Delivery Service for which stats will be returned or
just
+ * its "xml_id".
+ * @param start A date/time from which to start data collection.
+ * @param end A date/time at which to end data collection.
+ * @param interval A unit-suffixed interval over which data will be
+ * "binned".
+ * @param _ Unused - kept for compatibility with the "concrete" service.
+ * @param dataOnly If given and `true`, only returns the data series,
not
+ * any supplementing meta info found in the API response.
+ * @returns The response - either with or without supplementary meta
info as
+ * decided by `dataOnly`.
*/
public async getDSKBPS(
- d: string,
+ d: ResponseDeliveryService | string,
start: Date,
end: Date,
interval: string,
_: boolean,
dataOnly?: boolean
): Promise<Array<DataPoint> | DataResponse> {
- const ds = this.deliveryServices.filter(service=>service.xmlId
=== d)[0];
+ const xmlID = typeof(d) === "string" ? d : d.xmlId;
+ const ds = this.deliveryServices.find(service=>service.xmlId
=== xmlID);
if (!ds) {
throw new Error(`no such Delivery Service: ${d}`);
}
@@ -428,21 +495,27 @@ export class DeliveryServiceService {
}
/**
- * Gets total TPS data for a Delivery Service. To get TPS data broken
down by HTTP status, use {@link getAllDSTPSData}.
+ * Gets total TPS data for a Delivery Service. To get TPS data broken
down
+ * by HTTP status, use {@link getAllDSTPSData}.
*
- * @param d The name (xmlid) of the Delivery Service for which TPS
stats will be fetched
- * @param start The desired start date/time of the data range (must not
have nonzero milliseconds!)
- * @param end The desired end date/time of the data range (must not
have nonzero milliseconds!)
- * @param interval A string that describes the interval across which to
'bucket' data e.g. '60s'
+ * @param d The Delivery Service for which TPS stats will be fetched, or
+ * just its "xml_id".
+ * @param start The desired start date/time of the data range (must not
have
+ * nonzero milliseconds!).
+ * @param end The desired end date/time of the data range (must not have
+ * nonzero milliseconds!).
+ * @param interval A string that describes the interval across which to
+ * 'bucket' data e.g. '60s'.
* @returns The requested DataResponse.
*/
public async getDSTPS(
- d: string,
+ d: ResponseDeliveryService | string,
start: Date,
end: Date,
interval: string,
): Promise<DataResponse> {
- const ds = this.deliveryServices.filter(service=>service.xmlId
=== d)[0];
+ const xmlID = typeof(d) === "string" ? d : d.xmlId;
+ const ds = this.deliveryServices.find(service=>service.xmlId
=== xmlID);
if (!ds) {
throw new Error(`no such Delivery Service: ${d}`);
}
@@ -471,21 +544,27 @@ export class DeliveryServiceService {
}
/**
- * Gets total TPS data for a Delivery Service, as well as TPS data by
HTTP response type.
+ * Gets total TPS data for a Delivery Service, as well as TPS data by
HTTP
+ * response type.
*
- * @param d The name (xmlid) of the Delivery Service for which TPS
stats will be fetched
- * @param start The desired start date/time of the data range (must not
have nonzero milliseconds!)
- * @param end The desired end date/time of the data range (must not
have nonzero milliseconds!)
- * @param interval A string that describes the interval across which to
'bucket' data e.g. '60s'
+ * @param d The Delivery Service for which TPS stats will be fetched, or
+ * just its "xml_id".
+ * @param start The desired start date/time of the data range (must not
have
+ * nonzero milliseconds!).
+ * @param end The desired end date/time of the data range (must not have
+ * nonzero milliseconds!).
+ * @param interval A string that describes the interval across which to
+ * 'bucket' data e.g. '60s'.
* @returns The requested TPSData.
*/
public async getAllDSTPSData(
- d: string,
+ d: ResponseDeliveryService | string,
start: Date,
end: Date,
interval: string,
): Promise<TPSData> {
- const ds = this.deliveryServices.filter(service=>service.xmlId
=== d)[0];
+ const xmlID = typeof(d) === "string" ? d : d.xmlId;
+ const ds = this.deliveryServices.filter(service=>service.xmlId
=== xmlID);
if (!ds) {
throw new Error(`no such Delivery Service: ${d}`);
}
@@ -548,7 +627,7 @@ export class DeliveryServiceService {
/**
* Gets a Delivery Service's SSL Keys
*
- * @param ds The delivery service xmlid or object
+ * @param ds The Delivery Service or just its "xml_id".
* @returns The DS ssl keys
*/
public async getSSLKeys(ds: string | ResponseDeliveryService):
Promise<ResponseDeliveryServiceSSLKey> {
diff --git a/experimental/traffic-portal/src/app/api/testing/index.ts
b/experimental/traffic-portal/src/app/api/testing/index.ts
index f71fd42819..d11c8b9680 100644
--- a/experimental/traffic-portal/src/app/api/testing/index.ts
+++ b/experimental/traffic-portal/src/app/api/testing/index.ts
@@ -19,7 +19,6 @@ import {
CacheGroupService,
CDNService,
ChangeLogsService,
- CoordinateService,
DeliveryServiceService,
InvalidationJobService,
MiscAPIsService,
@@ -35,7 +34,6 @@ import {
import { CacheGroupService as TestingCacheGroupService } from
"./cache-group.service";
import { CDNService as TestingCDNService } from "./cdn.service";
import { ChangeLogsService as TestingChangeLogsService} from
"./change-logs.service";
-import { CoordinateService as TestingCoordinateService } from
"./coordinate.service";
import { DeliveryServiceService as TestingDeliveryServiceService } from
"./delivery-service.service";
import { InvalidationJobService as TestingInvalidationJobService } from
"./invalidation-job.service";
import { MiscAPIsService as TestingMiscAPIsService } from
"./misc-apis.service";
@@ -60,7 +58,6 @@ import { UserService as TestingUserService } from
"./user.service";
{provide: CacheGroupService, useClass:
TestingCacheGroupService},
{provide: ChangeLogsService, useClass:
TestingChangeLogsService},
{provide: CDNService, useClass: TestingCDNService},
- {provide: CoordinateService, useClass:
TestingCoordinateService},
{provide: DeliveryServiceService, useClass:
TestingDeliveryServiceService},
{provide: InvalidationJobService, useClass:
TestingInvalidationJobService},
{provide: MiscAPIsService, useClass: TestingMiscAPIsService},
diff --git a/experimental/traffic-portal/src/app/api/testing/origin.service.ts
b/experimental/traffic-portal/src/app/api/testing/origin.service.ts
index e85ec3f256..3a9e7e44a7 100644
--- a/experimental/traffic-portal/src/app/api/testing/origin.service.ts
+++ b/experimental/traffic-portal/src/app/api/testing/origin.service.ts
@@ -16,14 +16,13 @@ import type { RequestOrigin, RequestOriginResponse } from
"trafficops-types";
import {
CacheGroupService,
- CoordinateService,
DeliveryServiceService,
ProfileService,
UserService,
} from "..";
/**
- * CoordinateService exposes API functionality relating to Coordinates.
+ * OriginService exposes API functionality relating to Origins.
*/
@Injectable()
export class OriginService {
@@ -53,24 +52,31 @@ export class OriginService {
constructor(
private readonly userService: UserService,
- private readonly coordinateService: CoordinateService,
private readonly cacheGroupService: CacheGroupService,
private readonly profileService: ProfileService,
private readonly dsService: DeliveryServiceService
) {}
+ /**
+ * Gets a specific Origin.
+ *
+ * @param nameOrID Either the integral, unique identifier (number) or
name
+ * (string) of the Origin to be returned.
+ * @returns The requested Origin.
+ */
+ public async getOrigins(nameOrID: number | string):
Promise<RequestOriginResponse>;
+ /**
+ * Gets all Origins.
+ *
+ * @returns All stored Origins.
+ */
public async getOrigins(): Promise<Array<RequestOriginResponse>>;
- public async getOrigins(
- nameOrID: string | number
- ): Promise<RequestOriginResponse>;
-
/**
- * Gets one or all Coordinates from Traffic Ops.
+ * Gets one or all Origins.
*
- * @param nameOrID If given, returns only the ResponseCoordinate with
the given name
- * (string) or ID (number).
- * @returns An Array of ResponseCoordinate objects - or a single
ResponseCoordinate object if 'nameOrID'
- * was given.
+ * @param nameOrID Optionally the integral, unique identifier (number)
or
+ * name (string) of a single Origin to be returned.
+ * @returns The requested Origin(s).
*/
public async getOrigins(
nameOrID?: string | number
@@ -128,7 +134,7 @@ export class OriginService {
}
let coordinate = null;
if (!!origin?.coordinateId) {
- coordinate = await
this.coordinateService.getCoordinates(
+ coordinate = await
this.cacheGroupService.getCoordinates(
origin.coordinateId
);
}
diff --git
a/experimental/traffic-portal/src/app/api/testing/physical-location.service.ts
b/experimental/traffic-portal/src/app/api/testing/physical-location.service.ts
index 6fe4eafa4f..47f68e60b5 100644
---
a/experimental/traffic-portal/src/app/api/testing/physical-location.service.ts
+++
b/experimental/traffic-portal/src/app/api/testing/physical-location.service.ts
@@ -37,16 +37,26 @@ export class PhysicalLocationService {
zip: "0000"
}];
+ /**
+ * Gets all Physical Locations.
+ *
+ * @returns All stored Physical Locations.
+ */
public async getPhysicalLocations():
Promise<Array<ResponsePhysicalLocation>>;
+ /**
+ * Gets a specific Physical Location.
+ *
+ * @param nameOrID The name (string) or ID (number) of the Physical
Location
+ * to be returned.
+ * @returns The requested Physical Location.
+ */
public async getPhysicalLocations(nameOrID: string | number):
Promise<ResponsePhysicalLocation>;
-
/**
- * Gets one or all of PhysicalLocations from Traffic Ops.
+ * Gets one or all Physical Location(s).
*
- * @param nameOrID If given, returns only the ResponsePhysicalLocation
with the given name
- * (string) or ID (number).
- * @returns An Array of ResponsePhysicalLocation objects - or a single
ResponsePhysicalLocation object if 'nameOrID'
- * was given.
+ * @param nameOrID If given, returns only the PhysicalLocation with the
+ * given name (string) or ID (number).
+ * @returns The requested Physical Location(s).
*/
public async getPhysicalLocations(nameOrID?: string | number):
Promise<Array<ResponsePhysicalLocation> | ResponsePhysicalLocation> {
if(nameOrID) {
diff --git a/experimental/traffic-portal/src/app/api/testing/profile.service.ts
b/experimental/traffic-portal/src/app/api/testing/profile.service.ts
index 686273d3ff..f26916f228 100644
--- a/experimental/traffic-portal/src/app/api/testing/profile.service.ts
+++ b/experimental/traffic-portal/src/app/api/testing/profile.service.ts
@@ -144,12 +144,25 @@ export class ProfileService {
}
];
- public async getProfiles(idOrName: number | string):
Promise<ResponseProfile>;
+ /**
+ * Retrieves all Profiles.
+ *
+ * @returns The requested Profiles.
+ */
public async getProfiles(): Promise<Array<ResponseProfile>>;
/**
- * Retrieves Profiles from the API.
+ * Retrieves a specific Profile from the API.
+ *
+ * @param idOrName Specify either the integral, unique identifier
(number)
+ * of a specific Profile to retrieve, or its name (string).
+ * @returns The requested Profile.
+ */
+ public async getProfiles(idOrName: number | string):
Promise<ResponseProfile>;
+ /**
+ * Retrieves one or allProfiles from the API.
*
- * @param idOrName Specify either the integral, unique identifier
(number) of a specific Profile to retrieve, or its name (string).
+ * @param idOrName If given, only the Profile with this integral, unique
+ * identifier (number) or name (string) will be returned.
* @returns The requested Profile(s).
*/
public async getProfiles(idOrName?: number | string):
Promise<Array<ResponseProfile> | ResponseProfile> {
@@ -183,10 +196,10 @@ export class ProfileService {
}
/**
- * Creates a new profile.
+ * Creates a new Profile.
*
- * @param profile The profile to create.
- * @returns The created profile.
+ * @param profile The Profile to create.
+ * @returns The created Profile.
*/
public async createProfile(profile: RequestProfile):
Promise<ResponseProfile> {
const t = {
@@ -200,9 +213,9 @@ export class ProfileService {
}
/**
- * Updates an existing profile.
+ * Updates an existing Profile.
*
- * @param profile the profile to update.
+ * @param profile the Profile to update.
* @returns The success message.
*/
public async updateProfile(profile: ResponseProfile):
Promise<ResponseProfile> {
@@ -230,10 +243,10 @@ export class ProfileService {
}
/**
- * import profile from json or text file
+ * Imports a Profile along with all its associated Parameters.
*
- * @param profile imported date for profile creation.
- * @returns The created profile which is profileImportResponse with id
added.
+ * @param profile The specification of the Profile to be
imported/created.
+ * @returns The created Profile.
*/
public async importProfile(profile: ProfileImport):
Promise<ProfileImportResponse> {
const t = {
@@ -256,13 +269,26 @@ export class ProfileService {
}
];
- public async getParameters(id: number): Promise<ResponseParameter>;
+ /**
+ * Gets all Parameters.
+ *
+ * @returns The requested Parameters.
+ */
public async getParameters(): Promise<Array<ResponseParameter>>;
/**
- * Gets one or all Parameters from Traffic Ops
+ * Gets a specific Parameter.
+ *
+ * @param id The integral, unique identifier of the specific Parameter
to be
+ * returned.
+ * @returns The requested parameter.
+ */
+ public async getParameters(id: number): Promise<ResponseParameter>;
+ /**
+ * Gets one or all Parameters.
*
- * @param id The integral, unique identifier (number) of a single
parameter to be returned.
- * @returns The requested parameter(s).
+ * @param id If given, only the Parameter with this unique, integral
+ * identifier will be returned.
+ * @returns The requested Parameter(s).
*/
public async getParameters(id?: number): Promise<ResponseParameter |
Array<ResponseParameter>> {
if (id !== undefined) {
@@ -290,10 +316,10 @@ export class ProfileService {
}
/**
- * Creates a new parameter.
+ * Creates a new Parameter.
*
- * @param parameter The parameter to create.
- * @returns The created parameter.
+ * @param parameter The Parameter to create.
+ * @returns The created Parameter.
*/
public async createParameter(parameter: RequestParameter):
Promise<ResponseParameter> {
const t = {
@@ -327,8 +353,9 @@ export class ProfileService {
/**
* 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.
+ * @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>> {
diff --git a/experimental/traffic-portal/src/app/api/testing/server.service.ts
b/experimental/traffic-portal/src/app/api/testing/server.service.ts
index 38d80d3963..7227ec1e21 100644
--- a/experimental/traffic-portal/src/app/api/testing/server.service.ts
+++ b/experimental/traffic-portal/src/app/api/testing/server.service.ts
@@ -111,12 +111,25 @@ export class ServerService {
private readonly profileService: ProfileService
){}
- public async getServers(idOrName: number | string):
Promise<ResponseServer>;
+ /**
+ * Retrieves all servers.
+ *
+ * @returns The requested servers.
+ */
public async getServers(): Promise<Array<ResponseServer>>;
/**
- * Retrieves servers from the API.
+ * Retrieves a specific server.
*
- * @param idOrName Specify either the integral, unique identifier
(number) of a specific Server to retrieve, or its hostname (string).
+ * @param idOrName Either the (short) hostname (string) of the server
to be
+ * returned, or its ID (number).
+ * @returns The requested server.
+ */
+ public async getServers(idOrName: number | string):
Promise<ResponseServer>;
+ /**
+ * Retrieves one or all servers.
+ *
+ * @param idOrName Specify either the integral, unique identifier
(number)
+ * of a specific Server to retrieve, or its hostname (string).
* @returns The requested server(s).
*/
public async getServers(idOrName?: number | string):
Promise<Array<ResponseServer> | ResponseServer> {
@@ -216,13 +229,24 @@ export class ServerService {
return this.servers[index];
}
+ /**
+ * Fetches server "check" stats.
+ *
+ * @returns All Serverchecks Traffic Ops has.
+ */
public async getServerChecks(): Promise<Servercheck[]>;
+ /**
+ * Fetches a server's "check" stats.
+ *
+ * @param id The ID of the server whose "checks" will be returned.
+ * @returns The Servercheck for the server identified by `id`.
+ */
public async getServerChecks(id: number): Promise<Servercheck>;
/**
- * Fetches server "check" stats from Traffic Ops.
+ * Fetches server "check" stats.
*
- * @param id If given, will return only the checks for the server with
that ID.
- * @todo Ideally this filter would be implemented server-side; the data
set gets huge.
+ * @param id If given, will return only the checks for the server with
that
+ * ID.
* @returns Serverchecks - or a single Servercheck if ID was given.
*/
public async getServerChecks(id?: number): Promise<Servercheck |
Servercheck[]> {
@@ -236,12 +260,25 @@ export class ServerService {
return this.servers.map(serverCheck);
}
- public async getStatuses(idOrName: number | string):
Promise<ResponseStatus>;
+ /**
+ * Retrieves all Statuses.
+ *
+ * @returns The requested Statuses.
+ */
public async getStatuses(): Promise<Array<ResponseStatus>>;
/**
- * Retrieves Statuses from the API.
+ * Retrieves a specific Status.
+ *
+ * @param idOrName The ID (number) or Name (string) of a single Status
to be
+ * retrieved.
+ * @returns The requested Status.
+ */
+ public async getStatuses(idOrName: number | string):
Promise<ResponseStatus>;
+ /**
+ * Retrieves one or all Statuses.
*
- * @param idOrName An optional ID (number) or Name (string) used to
fetch a single Status thereby identified.
+ * @param idOrName An optional ID (number) or Name (string) used to
fetch a
+ * single Status thereby identified.
* @returns The requested Status(es).
*/
public async getStatuses(idOrName?: number | string):
Promise<Array<ResponseStatus> | ResponseStatus> {
diff --git a/experimental/traffic-portal/src/app/api/testing/type.service.ts
b/experimental/traffic-portal/src/app/api/testing/type.service.ts
index 4d5531feaf..f946aff8a4 100644
--- a/experimental/traffic-portal/src/app/api/testing/type.service.ts
+++ b/experimental/traffic-portal/src/app/api/testing/type.service.ts
@@ -145,12 +145,25 @@ export class TypeService {
}
];
- public async getTypes(idOrName: number | string):
Promise<TypeFromResponse>;
+ /**
+ * Gets all Types.
+ *
+ * @returns The requested Types.
+ */
public async getTypes(): Promise<Array<TypeFromResponse>>;
/**
- * Gets one or all Types from Traffic Ops
+ * Gets a specific Type.
+ *
+ * @param idOrName Either the integral, unique identifier (number) or
name
+ * (string) of the Type to be returned.
+ * @returns The requested Type.
+ */
+ public async getTypes(idOrName: number | string):
Promise<TypeFromResponse>;
+ /**
+ * Gets one or all Types.
*
- * @param idOrName Either the integral, unique identifier (number) or
name (string) of a single Type to be returned.
+ * @param idOrName Optionally the integral, unique identifier (number)
or
+ * name (string) of a single Type to be returned.
* @returns The requested Type(s).
*/
public async getTypes(idOrName?: number | string):
Promise<TypeFromResponse | Array<TypeFromResponse>> {
diff --git a/experimental/traffic-portal/src/app/api/testing/user.service.ts
b/experimental/traffic-portal/src/app/api/testing/user.service.ts
index 607e9f3ebe..9b1673f6ed 100644
--- a/experimental/traffic-portal/src/app/api/testing/user.service.ts
+++ b/experimental/traffic-portal/src/app/api/testing/user.service.ts
@@ -219,13 +219,26 @@ export class UserService {
return true;
}
+ /**
+ * Gets a specific User.
+ *
+ * @param nameOrID The username (string) or ID (number) of the User to
+ * fetch.
+ * @returns The requested User.
+ */
public async getUsers(nameOrID: string | number): Promise<ResponseUser>;
+ /**
+ * Gets all stored Users.
+ *
+ * @returns All Users that are visible to the current user's Tenant.
+ */
public async getUsers(): Promise<Array<ResponseUser>>;
/**
- * Gets an array of all users in Traffic Ops.
+ * Gets one or all Users.
*
- * @param nameOrID If given, returns only the User with the given
username (string) or ID (number).
- * @returns An Array of User objects - or a single User object if
'nameOrID' was given.
+ * @param nameOrID If given, returns only the User with the given
username
+ * (string) or ID (number).
+ * @returns The requested User(s).
*/
public async getUsers(nameOrID?: string | number):
Promise<Array<ResponseUser> | ResponseUser> {
if (nameOrID) {
diff --git a/experimental/traffic-portal/src/app/api/type.service.ts
b/experimental/traffic-portal/src/app/api/type.service.ts
index d2539bf248..8d7b748532 100644
--- a/experimental/traffic-portal/src/app/api/type.service.ts
+++ b/experimental/traffic-portal/src/app/api/type.service.ts
@@ -32,6 +32,12 @@ type UseInTable = "cachegroup" |
*/
@Injectable()
export class TypeService extends APIService {
+ /**
+ * Gets all Types from Traffic Ops.
+ *
+ * @returns The requested Types.
+ */
+ public async getTypes(): Promise<Array<TypeFromResponse>>;
/**
* Gets a specific Type from Traffic Ops.
*
@@ -40,14 +46,6 @@ export class TypeService extends APIService {
* @returns The requested Type.
*/
public async getTypes(idOrName: number | string):
Promise<TypeFromResponse>;
- /**
- * Gets Types from Traffic Ops.
- *
- * @param idOrName Either the integral, unique identifier (number) or
name
- * (string) of a single Type to be returned.
- * @returns The requested Type(s).
- */
- public async getTypes(): Promise<Array<TypeFromResponse>>;
/**
* Gets one or all Types from Traffic Ops.
*
diff --git
a/experimental/traffic-portal/src/app/core/deliveryservice/ds-card/ds-card.component.html
b/experimental/traffic-portal/src/app/core/deliveryservice/ds-card/ds-card.component.html
index c91862995b..ac55cf8e03 100644
---
a/experimental/traffic-portal/src/app/core/deliveryservice/ds-card/ds-card.component.html
+++
b/experimental/traffic-portal/src/app/core/deliveryservice/ds-card/ds-card.component.html
@@ -47,7 +47,7 @@ limitations under the License.
<div class="capacity">
<label
for="{{deliveryService.id}}-utilized">Utilized:</label><meter
id="{{deliveryService.id}}-utilized" max="100" low="25" high="75" optimum="5"
value="{{utilized}}" title="{{utilized}} percent">{{utilized}}%</meter>
<label
for="{{deliveryService.id}}-available">Available:</label><meter
id="{{deliveryService.id}}-available" max="100" low="25" high="75" optimum="95"
value="{{available}}" title="{{available}} percent">{{available}}%</meter>
- <label
for="{{deliveryService.id}}-maintenance">Under Mainenance:</label><meter
id="{{deliveryService.id}}-maintenance" max="100" low="10" high="20"
optimum="0" value="{{maintenance}}" title="{{maintenance}}
percent">{{maintenance}}%</meter>
+ <label
for="{{deliveryService.id}}-maintenance">Under Maintenance:</label><meter
id="{{deliveryService.id}}-maintenance" max="100" low="10" high="20"
optimum="0" value="{{maintenance}}" title="{{maintenance}}
percent">{{maintenance}}%</meter>
</div>
</fieldset>
<fieldset class="health">
diff --git
a/experimental/traffic-portal/src/app/core/origins/detail/origin-detail.component.ts
b/experimental/traffic-portal/src/app/core/origins/detail/origin-detail.component.ts
index 33d199da1e..1d9c64046a 100644
---
a/experimental/traffic-portal/src/app/core/origins/detail/origin-detail.component.ts
+++
b/experimental/traffic-portal/src/app/core/origins/detail/origin-detail.component.ts
@@ -28,7 +28,6 @@ import type {
import {
CacheGroupService,
- CoordinateService,
DeliveryServiceService,
OriginService,
ProfileService,
@@ -64,7 +63,6 @@ export class OriginDetailComponent implements OnInit {
private readonly navSvc: NavigationService,
private readonly log: LoggingService,
private readonly userService: UserService,
- private readonly coordinateService: CoordinateService,
private readonly cacheGroupService: CacheGroupService,
private readonly profileService: ProfileService,
private readonly dsService: DeliveryServiceService
@@ -76,7 +74,7 @@ export class OriginDetailComponent implements OnInit {
public async ngOnInit(): Promise<void> {
this.tenants = await this.userService.getTenants();
this.cacheGroups = await
this.cacheGroupService.getCacheGroups();
- this.coordinates = await
this.coordinateService.getCoordinates();
+ this.coordinates = await
this.cacheGroupService.getCoordinates();
this.profiles = await this.profileService.getProfiles();
this.deliveryServices = await
this.dsService.getDeliveryServices();
this.protocols = ["http", "https"];
diff --git
a/experimental/traffic-portal/src/app/shared/tree-select/tree-select.component.html
b/experimental/traffic-portal/src/app/shared/tree-select/tree-select.component.html
index 69b11e2256..3e4fa50c5b 100644
---
a/experimental/traffic-portal/src/app/shared/tree-select/tree-select.component.html
+++
b/experimental/traffic-portal/src/app/shared/tree-select/tree-select.component.html
@@ -23,7 +23,7 @@ limitations under the License.
</mat-form-field>
<mat-tree [dataSource]="treeData" [treeControl]="treeControl">
<mat-tree-node *matTreeNodeDef="let node"
matTreeNodeToggle [style.display]="!isVisible(node) ? 'none' : 'block'">
- <div mat-menu-item (click)="select(node)">
+ <div mat-menu-item (click)="select(node)"
(keypress.enter)="select(node)">
{{node.name}}
</div>
</mat-tree-node>
@@ -34,7 +34,7 @@ limitations under the License.
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right' }}
</mat-icon>
</button>
- <div mat-menu-item
(click)="select(node)">
+ <div mat-menu-item
(click)="select(node)" (keypress.enter)="select(node)">
{{node.name}}
</div>
</div>