Record Class CourseApiKeyView
java.lang.Object
java.lang.Record
edu.ucsb.cs156.frontiers.models.CourseApiKeyView
- Record Components:
id- the key's id, used to revoke itlabel- the name the instructor gave the key, or nullkeySuffix- the last six characters of the keycreatedByEmail- the email of the user who created the keycreatedAt- when the key was createdexpiresAt- when the key stops workinglastUsedAt- when the key was last used, or null if neverusageCount- how many requests have been made with the keyrevoked- whether the key has been revokedstatus- ACTIVE, EXPIRED or REVOKED, as of the time the view was built
public record CourseApiKeyView(Long id, String label, String keySuffix, String createdByEmail, ZonedDateTime createdAt, ZonedDateTime expiresAt, ZonedDateTime lastUsedAt, Long usageCount, boolean revoked, CourseApiKeyView.Status status)
extends Record
What an instructor may see about one of their course's API keys: everything except the key
itself, which is never stored and so can never be shown again. The last six characters of the key
(
keySuffix) are enough to tell keys apart without compromising them.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhether a key can currently be used. -
Constructor Summary
ConstructorsConstructorDescriptionCourseApiKeyView(Long id, String label, String keySuffix, String createdByEmail, ZonedDateTime createdAt, ZonedDateTime expiresAt, ZonedDateTime lastUsedAt, Long usageCount, boolean revoked, CourseApiKeyView.Status status) Creates an instance of aCourseApiKeyViewrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecreatedAtrecord component.Returns the value of thecreatedByEmailrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpiresAtrecord component.static CourseApiKeyViewfrom(CourseApiKey key, ZonedDateTime now) Builds the view of a key as of the given moment.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.Returns the value of thekeySuffixrecord component.label()Returns the value of thelabelrecord component.Returns the value of thelastUsedAtrecord component.booleanrevoked()Returns the value of therevokedrecord component.status()Returns the value of thestatusrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of theusageCountrecord component.
-
Constructor Details
-
CourseApiKeyView
public CourseApiKeyView(Long id, String label, String keySuffix, String createdByEmail, ZonedDateTime createdAt, ZonedDateTime expiresAt, ZonedDateTime lastUsedAt, Long usageCount, boolean revoked, CourseApiKeyView.Status status) Creates an instance of aCourseApiKeyViewrecord class.- Parameters:
id- the value for theidrecord componentlabel- the value for thelabelrecord componentkeySuffix- the value for thekeySuffixrecord componentcreatedByEmail- the value for thecreatedByEmailrecord componentcreatedAt- the value for thecreatedAtrecord componentexpiresAt- the value for theexpiresAtrecord componentlastUsedAt- the value for thelastUsedAtrecord componentusageCount- the value for theusageCountrecord componentrevoked- the value for therevokedrecord componentstatus- the value for thestatusrecord component
-
-
Method Details
-
from
Builds the view of a key as of the given moment.- Parameters:
key- the keynow- the current time, used to decide whether the key has expired- Returns:
- the view
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
id
-
label
-
keySuffix
-
createdByEmail
Returns the value of thecreatedByEmailrecord component.- Returns:
- the value of the
createdByEmailrecord component
-
createdAt
-
expiresAt
-
lastUsedAt
Returns the value of thelastUsedAtrecord component.- Returns:
- the value of the
lastUsedAtrecord component
-
usageCount
Returns the value of theusageCountrecord component.- Returns:
- the value of the
usageCountrecord component
-
revoked
-
status
-