You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by oc...@apache.org on 2023/01/25 15:32:05 UTC

[trafficcontrol-trafficops-types] branch 4.x created (now 2e69198)

This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a change to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git


      at 2e69198  Version bump

This branch includes the following new commits:

     new d2a7918  Add CDN Locks
     new 8a1ce76  Update DSRs
     new b2762f5  Update DSs
     new 1644fc3  Add ACME generation request structure, deprecate LetsEncrypt
     new c69fcbf  Add cert SANs
     new 971f90f  Add new server update status fields
     new f226ffd  Restructure Invalidation Jobs for v4
     new 58e1ee4  Update User structures for v4
     new 51c88a8  Update Role structure for v4
     new 2e69198  Version bump

The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[trafficcontrol-trafficops-types] 07/10: Restructure Invalidation Jobs for v4

Posted by oc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit f226ffd1933451b6f733e9b5be3e176186a3de8e
Author: ocket8888 <oc...@apache.org>
AuthorDate: Tue Jan 24 09:43:01 2023 -0700

    Restructure Invalidation Jobs for v4
---
 src/invalidation.ts | 54 ++++++++++++++++++++++-------------------------------
 1 file changed, 22 insertions(+), 32 deletions(-)

diff --git a/src/invalidation.ts b/src/invalidation.ts
index d05f87d..c09bb98 100644
--- a/src/invalidation.ts
+++ b/src/invalidation.ts
@@ -18,8 +18,16 @@
 
 /** JobType enumerates the valid types of Job. */
 export const enum JobType {
-	/** Content Invalidation Request. */
-	PURGE = "PURGE"
+	/**
+	 * Requests that cache servers ignore caching rules and forcibly retrieve a
+	 * new copy of the content.
+	 *
+	 * @deprecated This should never be necessary, as it only has value when an
+	 * Origin doesn't respect HTTP standards.
+	 */
+	REFETCH = "REFETCH",
+	/** Requests that cache servers treat content as stale. */
+	REFRESH = "REFRESH"
 }
 
 /**
@@ -32,26 +40,18 @@ export interface ResponseInvalidationJob {
 	 * "revalidated".
 	 */
 	assetURL: string;
-	/**
-	 * The name of the user that created the Job.
-	 */
+	/** The name of the user that created the Job. */
 	createdBy: string;
 	/** The XMLID of the Delivery Service within which the Job will operate. */
 	deliveryService: string;
 	/** An integral, unique identifier for this Job. */
 	readonly id: number;
 	/** The type of Job. */
-	keyword: JobType;
-	/**
-	 * though not enforced by the API (or database), this should ALWAYS have the
-	 * format 'TTL:nh', describing the job's TTL in hours (`n` can be any
-	 * integer value > 0).
-	 */
-	parameters: string;
-	/**
-	 * The time at which the Job is scheduled to start.
-	 */
+	invalidationType: JobType;
+	/** The time at which the Job is scheduled to start. */
 	startTime: Date;
+	/** The number of hours for which the Job will remain active. */
+	ttlHours: number;
 }
 
 /**
@@ -59,24 +59,14 @@ export interface ResponseInvalidationJob {
  * content invalidation job through the API.
  */
 export interface RequestInvalidationJob {
-	/**
-	 * This may be either the ID or the XMLID of the Delivery Service to which
-	 * the Job will apply.
-	 */
-	deliveryService: number | string;
-	/**
-	 * The effective starting date/time for the Job.
-	 */
-	startTime: Date | string;
-	/**
-	 * A pattern that matches content to be invalidated.
-	 */
+	/** The XMLID of the Delivery Service to which the Job will apply. */
+	deliveryService: string;
+	/** A pattern that matches content to be invalidated. */
 	regex: string;
-	/**
-	 * Either the number of hours or a "duration string" describing for how
-	 * long the Job will remain in effect.
-	 */
-	ttl: number | string;
+	/** The effective starting date/time for the Job. */
+	startTime: Date | string;
+	/** The number of hours for which the Job will remain in effect. */
+	ttlHours: number;
 }
 
 /** Represents a content invalidation job. */


[trafficcontrol-trafficops-types] 03/10: Update DSs

Posted by oc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit b2762f5559af03e54a0243a343773c79c9203ec3
Author: ocket8888 <oc...@apache.org>
AuthorDate: Wed Nov 23 19:05:47 2022 -0700

    Update DSs
---
 src/delivery.service.ts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/delivery.service.ts b/src/delivery.service.ts
index 0988cb6..e56959b 100644
--- a/src/delivery.service.ts
+++ b/src/delivery.service.ts
@@ -359,6 +359,8 @@ interface RequestDeliveryServiceBase {
 	 * Service belongs.
 	 */
 	tenantId: number;
+	/** A list of explicitly supported TLS versions. */
+	tlsVersions?: undefined | null | [string, ...string[]];
 	topology?: string | null;
 	/**
 	 * HTTP headers that should be logged from client requests by Traffic
@@ -664,6 +666,8 @@ interface ResponseDeliveryServiceBase {
 	 * Service belongs.
 	 */
 	tenantId: number;
+	/** A list of explicitly supported TLS versions. */
+	tlsVersions: null | [string, ...string[]];
 	topology: string | null;
 	/** Extra HTTP headers that Traffic Router should provide in responses. */
 	trResponseHeaders: string | null;


[trafficcontrol-trafficops-types] 02/10: Update DSRs

Posted by oc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit 8a1ce7604b5e649b7f751e066a6ec4595138325b
Author: ocket8888 <oc...@apache.org>
AuthorDate: Wed Nov 23 18:49:39 2022 -0700

    Update DSRs
---
 src/delivery.service.request.ts | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/delivery.service.request.ts b/src/delivery.service.request.ts
index c60221d..e83c158 100644
--- a/src/delivery.service.request.ts
+++ b/src/delivery.service.request.ts
@@ -137,7 +137,12 @@ export type DeliveryServiceRequest = ResponseDeliveryServiceRequest | RequestDel
  * Both an undefined value and `null` mean "remove the current assignee".
  */
 export interface DeliveryServiceAssignmentChangeRequest {
-	assigneeId?: number | null;
+	assignee?: string | null | undefined;
+	/**
+	 * In the event that `assignee` and `assigneeId` identify different users,
+	 * the `assigneeId` will take precedence.
+	 */
+	assigneeId?: number | null | undefined;
 }
 
 /**


[trafficcontrol-trafficops-types] 10/10: Version bump

Posted by oc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit 2e691982a5114c10044b7734abd412809ea382ee
Author: ocket8888 <oc...@apache.org>
AuthorDate: Wed Jan 25 08:23:51 2023 -0700

    Version bump
---
 package-lock.json | 4 ++--
 package.json      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index e4feaf3..1409ff4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
 	"name": "trafficops-types",
-	"version": "3.1.4",
+	"version": "4.0.0",
 	"lockfileVersion": 2,
 	"requires": true,
 	"packages": {
 		"": {
 			"name": "trafficops-types",
-			"version": "3.1.4",
+			"version": "4.0.0",
 			"license": "Apache-2.0",
 			"devDependencies": {
 				"@typescript-eslint/eslint-plugin": "^5.0.0",
diff --git a/package.json b/package.json
index aea97a9..168f7b2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "trafficops-types",
-	"version": "3.1.4",
+	"version": "4.0.0",
 	"description": "A library for dealing with Apache Traffic Control objects",
 	"main": "dist/index.js",
 	"scripts": {


[trafficcontrol-trafficops-types] 08/10: Update User structures for v4

Posted by oc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit 58e1ee406d687f1211f84744948920bfd9a7ebc1
Author: ocket8888 <oc...@apache.org>
AuthorDate: Tue Jan 24 14:08:12 2023 -0700

    Update User structures for v4
---
 src/user.ts | 117 +++++++++++++-----------------------------------------------
 1 file changed, 25 insertions(+), 92 deletions(-)

diff --git a/src/user.ts b/src/user.ts
index 50e1e49..43fa2e4 100644
--- a/src/user.ts
+++ b/src/user.ts
@@ -33,14 +33,15 @@ export interface PostRequestUser {
 	/** @deprecated This has no purpose and should never be used. */
 	gid?: number | null;
 	localPasswd: string;
+	/** @deprecated This has no purpose and should never be used. */
 	newUser?: boolean | null;
 	phoneNumber?: string | null;
 	postalCode?: string | null;
 	publicSshKey?: string | null;
-	role: number;
+	role: string;
 	stateOrProvince?: string | null;
-	tenantId?: never;
-	tenantID: number;
+	tenantId: number;
+	ucdn?: string | null;
 	/** @deprecated This has no purpose and should never be used. */
 	uid?: number | null;
 	username: string;
@@ -64,10 +65,11 @@ interface PutRequestNotChangingPasswordUser {
 	phoneNumber?: string | null;
 	postalCode?: string | null;
 	publicSshKey?: string | null;
-	role: number;
+	role: string;
 	stateOrProvince?: string | null;
 	tenantId?: never;
 	tenantID: number;
+	ucdn?: string | null;
 	/** @deprecated This has no purpose and should never be used. */
 	uid?: number | null;
 	username: string;
@@ -83,10 +85,11 @@ export type PutRequestUser = PostRequestUser | PutRequestNotChangingPasswordUser
 /** Generically represents a user in the context of a request. */
 export type RequestUser = PutRequestUser | PostRequestUser;
 
-/** Groups the fields common to responses from /users in all contexts. */
-interface ResponseUserBase {
+/** Generically represents a user in the context of a response. */
+export interface ResponseUser {
 	addressLine1: string | null;
 	addressLine2: string | null;
+	readonly changeLogCount: number;
 	city: string | null;
 	company: string | null;
 	country: string | null;
@@ -94,61 +97,30 @@ interface ResponseUserBase {
 	fullName: string;
 	/** @deprecated This has no purpose and should never be used. */
 	gid: number | null;
-	id: number;
-	/**
-	 * This is actually a string that represents a date/time, in a custom
-	 * format. Refer to
-	 * [the Traffic Ops API documentation](https://traffic-control-cdn.readthedocs.io/en/latest/api/index.html#traffic-ops-s-custom-date-time-format)
-	 * for details.
-	 */
+	readonly id: number;
+	readonly lastAuthenticated: Date | null;
 	readonly lastUpdated: Date;
+	/** @deprecated This has no known purpose and shouldn't be used. */
 	newUser: boolean | null;
 	phoneNumber: string | null;
 	postalCode: string | null;
 	publicSshKey: string | null;
-	/**
-	 * This is actually a string that represents a date/time, in a custom
-	 * format. Refer to
-	 * [the Traffic Ops API documentation](https://traffic-control-cdn.readthedocs.io/en/latest/api/index.html#traffic-ops-s-custom-date-time-format)
-	 * for details.
-	 */
 	registrationSent?: null | Date;
-	role: number;
+	role: string;
 	stateOrProvince: string | null;
 	tenant: string;
-	tenantID?: never;
 	tenantId: number;
+	ucdn: string;
 	/** @deprecated This has no purpose and should never be used. */
 	uid: number | null;
 	username: string;
 }
 
-/** Represents a response from /users to a PUT or POST request. */
-export interface PutOrPostResponseUser extends ResponseUserBase {
-	/**
-	 * This appears only in response to POST requests, or to PUT requests where
-	 * the user's password was changed.
-	 */
-	confirmLocalPasswd?: string;
-	rolename?: never;
-	roleName: string;
-}
-
-/** Represents a response from /users to a GET request. */
-export interface GetResponseUser extends ResponseUserBase {
-	confirmLocalPasswd?: never;
-	rolename: string;
-	roleName?: never;
-}
-
-/** Generically represents a user in the context of a response. */
-export type ResponseUser = GetResponseUser | PutOrPostResponseUser;
-
 /**
  * User generically represents a user in the context of a PUT, POST, or GET
  * request or response to/from /users.
  */
-export type User = PutRequestUser | PostRequestUser | PutOrPostResponseUser | GetResponseUser;
+export type User = RequestUser | ResponseUser;
 
 /**
  * ResponseCurrentUser represents a response from /user/current.
@@ -162,22 +134,16 @@ export interface ResponseCurrentUser {
 	email: `${string}@${string}.${string}`;
 	fullName: string;
 	gid: number | null;
-	id: number;
-	/**
-	 * This is actually a string that represents a date/time, in a custom
-	 * format. Refer to
-	 * [the Traffic Ops API documentation](https://traffic-control-cdn.readthedocs.io/en/latest/api/index.html#traffic-ops-s-custom-date-time-format)
-	 * for details.
-	 */
+	readonly id: number;
+	readonly lastAuthenticated: null | Date;
 	readonly lastUpdated: Date;
 	localUser: boolean;
 	newUser: boolean;
 	phoneNumber: string | null;
 	postalCode: string | null;
 	publicSshKey: string | null;
-	role: number;
-	rolename?: never;
-	roleName: string;
+	readonly registrationSent: null | Date;
+	role: string;
 	stateOrProvince: string | null;
 	tenant: string;
 	tenantId: number;
@@ -196,8 +162,7 @@ export function userEmailIsValid(email: string): email is `${string}@${string}.$
 }
 
 /**
- * Currently, a request to /user/current has no properties. This bug is tracked
- * by apache/trafficcontrol#6367.
+ * Represents a request to modify the current user.
  */
 export interface RequestCurrentUser {
 	addressLine1?: string | null;
@@ -205,57 +170,25 @@ export interface RequestCurrentUser {
 	city?: string | null;
 	company?: string | null;
 	country?: string | null;
-	/**
-	 * Note that while this is allowed to be null or undefined, it will **not**
-	 * be allowed to be either of those things as a property of a
-	 * {@link PostRequestUser} nor as a property of a {@link PutRequestUser}.
-	 * This means that setting it as such can cause problems for future requests
-	 * and should be avoided whenever possible.
-	 */
-	email?: string | null;
-	/**
-	 * Note that while this is allowed to be null or undefined, it will **not**
-	 * be allowed to be either of those things as a property of a
-	 * {@link PostRequestUser} nor as a property of a {@link PutRequestUser}.
-	 * This means that setting it as such can cause problems for future requests
-	 * and should be avoided whenever possible.
-	 */
-	fullName?: string | null;
+	email: string;
+	fullName: string;
 	/**
 	 * @deprecated This serves no purpose and is subject to removal in the
 	 * future.
 	 */
 	gid?: number | null;
-	localUser?: boolean | null;
-	newUser?: boolean | null;
 	phoneNumber?: string | null;
 	postalCode?: string | null;
 	publicSshKey?: string | null;
-	/**
-	 * Unlike in virtually every other context, this is allowed to be `null` or
-	 * undefined. In that case, it has the meaning "leave this unchanged" rather
-	 * than setting it to `null` as with most other properties.
-	 */
-	role?: number | null;
+	role: string;
 	stateOrProvince?: string | null;
-	/**
-	 * Unlike in virtually every other context, this is allowed to be `null` or
-	 * undefined. In that case, it has the meaning "leave this unchanged" rather
-	 * than setting it to `null` as with most other properties.
-	 */
-	tenantId?: number | null;
-	tenantID?: never;
+	tenantId: number;
 	/**
 	 * @deprecated This serves no purpose and is subject to removal in the
 	 * future.
 	 */
 	uid?: number | null;
-	/**
-	 * Unlike in virtually every other context, this is allowed to be `null` or
-	 * undefined. In that case, it has the meaning "leave this unchanged" rather
-	 * than setting it to `null` as with most other properties.
-	 */
-	username?: never;
+	username: string;
 }
 
 /**


[trafficcontrol-trafficops-types] 01/10: Add CDN Locks

Posted by oc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit d2a7918c763450179f273d5b57ae496a34b15dd6
Author: ocket8888 <oc...@apache.org>
AuthorDate: Wed Nov 23 18:40:44 2022 -0700

    Add CDN Locks
---
 src/cdn.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/src/cdn.ts b/src/cdn.ts
index 1ef9204..14595a3 100644
--- a/src/cdn.ts
+++ b/src/cdn.ts
@@ -53,3 +53,51 @@ export interface CDNDomain {
 	profileName: string;
 	profileDescription: string;
 }
+
+/**
+ * Represents a CDN Lock as returned by the Traffic Ops API in responses.
+ */
+export interface ResponseCDNLock {
+	/** The username for which the lock exists. */
+	readonly userName: string;
+	/** The name of the CDN for which the lock exists. */
+	readonly cdn: string;
+	/**
+	 * The message or reason that the user specified while acquiring the lock.
+	 */
+	readonly message: string | null;
+	/** Whether or not this is a soft (shared) lock. */
+	readonly soft: boolean;
+	/**
+	 * An array of the usernames that the creator of the lock has shared their
+	 * lock with.
+	 */
+	readonly sharedUserNames: readonly string[] | null;
+	/** Time that this lock was last updated(created). */
+	readonly lastUpdated: Date;
+}
+
+/**
+ * Represents a CDN Lock as required by Traffic Ops in requests.
+ */
+export interface RequestCDNLock {
+	/** The name of the CDN for which the lock exists. */
+	cdn: string;
+	/**
+	 * The message or reason that the user specified while acquiring the lock.
+	 */
+	message?: string | null | undefined;
+	/** Whether or not this is a soft (shared) lock. */
+	soft: boolean;
+	/**
+	 * An array of the usernames that the creator of the lock has shared their
+	 * lock with.
+	 */
+	sharedUserNames?: string[] | null | undefined;
+}
+
+/**
+ * Represents a lock on a CDN that prevents other uses from making changes to
+ * resources scoped within it.
+ */
+export type CDNLock = RequestCDNLock | ResponseCDNLock;


[trafficcontrol-trafficops-types] 04/10: Add ACME generation request structure, deprecate LetsEncrypt

Posted by oc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit 1644fc327debc227068b5083e038e824be2bfb47
Author: ocket8888 <oc...@apache.org>
AuthorDate: Wed Nov 23 19:47:59 2022 -0700

    Add ACME generation request structure, deprecate LetsEncrypt
---
 src/ssl.ts | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/src/ssl.ts b/src/ssl.ts
index 2cc9717..ce287ac 100644
--- a/src/ssl.ts
+++ b/src/ssl.ts
@@ -75,6 +75,9 @@ export interface DeliveryServiceSSLKeyGenerationRequest {
  * Represents a request to have Traffic Ops generate an SSL Key/Certificate pair
  * for a Delivery Service using LetsEncrypt (or another configured ACME
  * service).
+ *
+ * @deprecated This has been superseded by the more general
+ * {@link ACMEDeliveryServiceSSLKeyGenerationRequest}.
  */
 export interface LetsEncryptDeliveryServiceSSLKeyGenerationRequest {
 	cdn: string;
@@ -84,6 +87,40 @@ export interface LetsEncryptDeliveryServiceSSLKeyGenerationRequest {
 	version: string;
 }
 
+/**
+ * Represents a request to have Traffic Ops request an SSL Key/Certificate pair
+ * for a Delivery Service from an ACME provider.
+ */
+export interface ACMEDeliveryServiceSSLKeyGenerationRequest{
+	/**
+	 * The certificate provider correlating to an ACME account in cdn.conf or
+	 * Let’s Encrypt.
+	 */
+	authType: string;
+	/**
+	 * The XMLID of the Delivery Service for which keys will be generated.
+	 *
+	 * Either the `key` or the `deliveryservice` field must be provided. If both
+	 * are provided, then they must match.
+	 */
+	key?: string | null | undefined;
+	/**
+	 * The XMLID of the Delivery Service for which keys will be generated.
+	 *
+	 * Either the `key` or the `deliveryservice` field must be provided. If both
+	 * are provided, then they must match.
+	 */
+	deliveryservice?: string | null | undefined;
+	/**
+	 * An integer that defines the "version" of the key - which may be thought
+	 * of as the sequential generation; that is, the higher the number the more
+	 * recent the key.
+	 */
+	version: string;
+	/** The desired hostname of the Delivery Service. */
+	hostname: string;
+}
+
 /**
  * Represents a Delivery Service's SSL Key/Certificate pair as presented by
  * Traffic Ops in responses.


[trafficcontrol-trafficops-types] 05/10: Add cert SANs

Posted by oc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit c69fcbf0a30e93383196eb0632293dd6b0f3642f
Author: ocket8888 <oc...@apache.org>
AuthorDate: Thu Dec 8 08:59:07 2022 -0700

    Add cert SANs
---
 src/ssl.ts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/ssl.ts b/src/ssl.ts
index ce287ac..946e007 100644
--- a/src/ssl.ts
+++ b/src/ssl.ts
@@ -141,4 +141,5 @@ export interface ResponseDeliveryServiceSSLKey {
 	state?: string;
 	version: string;
 	expiration: Date;
+	sans?: [string, ...string[]];
 }


[trafficcontrol-trafficops-types] 06/10: Add new server update status fields

Posted by oc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit 971f90f41dbdd612f5a62320cf8437bbe3867ae6
Author: ocket8888 <oc...@apache.org>
AuthorDate: Thu Dec 8 08:59:19 2022 -0700

    Add new server update status fields
---
 src/server.ts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/server.ts b/src/server.ts
index 8ec04f9..f1ca9c1 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -527,11 +527,15 @@ export interface ServerDetails  {
  * current state.
  */
 export interface ServerUpdateStatus {
+	configApplyTime: Date;
+	configUpdateTime: Date;
 	/* eslint-disable @typescript-eslint/naming-convention */
 	host_id: number;
 	host_name: string;
 	parent_pending: boolean;
 	parent_reval_pending: boolean;
+	revalUpdateTime: Date;
+	revalApplyTime: Date;
 	reval_pending: boolean;
 	status: string;
 	upd_pending: boolean;


[trafficcontrol-trafficops-types] 09/10: Update Role structure for v4

Posted by oc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit 51c88a8f67098e074325edabe7131655daedae43
Author: ocket8888 <oc...@apache.org>
AuthorDate: Tue Jan 24 14:08:33 2023 -0700

    Update Role structure for v4
---
 src/user.ts | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/user.ts b/src/user.ts
index 43fa2e4..0fa9972 100644
--- a/src/user.ts
+++ b/src/user.ts
@@ -203,19 +203,35 @@ export type CurrentUser = ResponseCurrentUser | RequestCurrentUser;
  * Represents a Role as Traffic Ops requires it in requests.
  */
 export interface RequestRole {
-	capabilities: Array<string>;
+	/**
+	 * This will be null in responses if it is null or undefined in the request.
+	 */
+	permissions?: Array<string> | null;
 	description: string;
 	name: string;
-	privLevel: number;
 }
 
 /**
- * Represents a Role as Traffic Ops presents it in responses.
+ * Represents a Role in a response to a PUT request.
+ *
+ * Note that this should not be different from a `PostResponseRole` - but
+ * currently is (because it's missing `lastUpdated`). This bug is tracked by
+ * [apache/trafficcontrol#7248](https://github.com/apache/trafficcontrol/issues/7248).
  */
-export interface ResponseRole extends RequestRole {
-	readonly id: number;
+export type PutResponseRole = RequestRole;
+
+/**
+ * Represents a Role as Traffic Ops presents it in responses to POST requests.
+ */
+export interface PostResponseRole extends PutResponseRole {
+	readonly lastUpdated: Date;
 }
 
+/**
+ * Represents a Role as Traffic Ops presents it in responses.
+ */
+export type ResponseRole = PutResponseRole | PostResponseRole;
+
 /**
  * A Role encapsulates the permissions to perform operations through the Traffic
  * Ops API.