Class GrantRequest

java.lang.Object
io.jenkins.plugins.batchcontrol.model.GrantRequest

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final class GrantRequest extends Object
A request for a temporary (JIT) change permission (SPEC item 8, section 3). Persisted as XStream XML at requests/grant/<id>.xml.

Timestamps are persisted as epoch milliseconds (long) because the Jenkins XStream class filter does not allow java.time.Instant; the accessors expose Instant.

Status transitions must only be performed by the policy services (policy.GrantRequestService); other code must not call setStatus(io.jenkins.plugins.batchcontrol.model.RequestStatus).

  • Method Details

    • create

      public static GrantRequest create(GrantScope scope, ItemKind itemKind, List<GrantAction> actions, int durationMinutes, String reason, String requester, List<String> approvers, String createNamePattern)
      Creates a new PENDING grant request with a random UUID id (D-68) and its creation time from BatchClock, recording the kind of the scope item (D-71). Duplicate actions are collapsed while preserving order.
    • create

      public static GrantRequest create(GrantScope scope, List<GrantAction> actions, int durationMinutes, String reason, String requester, List<String> approvers, String createNamePattern)
      As create(GrantScope, ItemKind, List, int, String, String, List, String) without an item kind. Such a request cannot be approved (D-71); kept for store fixtures.
    • create

      public static GrantRequest create(GrantScope scope, List<GrantAction> actions, int durationMinutes, String reason, String requester, String approver)
      Single-approver form without a name restriction, kept for callers written before D-37.
    • getId

      public String getId()
    • getScope

      public GrantScope getScope()
    • getItemKind

      public ItemKind getItemKind()
      D-71: the kind of the scope item recorded at creation, or null when none was recorded.
    • getActions

      public List<GrantAction> getActions()
      A defensive copy; the requested actions never change after creation.
    • getDurationMinutes

      public int getDurationMinutes()
    • getReason

      public String getReason()
    • getRequester

      public String getRequester()
    • getApprovers

      public List<String> getApprovers()
      The designated approver set (D-37), in designation order.
    • getApprover

      public String getApprover()
      Compatibility view (D-37): the first designated approver, or null with none.
    • isDesignatedApprover

      public boolean isDesignatedApprover(String userId)
      Whether userId is a member of the designated set.
    • getDecidedBy

      public String getDecidedBy()
      The user who closed the request: the approver who approved or rejected it, or the user who cancelled it (e2e-03 DEF-13); null while undecided.
    • getCreateNamePattern

      public String getCreateNamePattern()
      D-40: the CREATE name restriction as written (/regex/ or exact name), or null.
    • getApproverChanges

      public List<GrantRequest.ApproverChange> getApproverChanges()
    • isExpiringNotified

      public boolean isExpiringNotified()
      Whether the D-36 EXPIRING notification was already sent.
    • getStatus

      public RequestStatus getStatus()
    • getCreatedAt

      public Instant getCreatedAt()
    • getDecidedAt

      public Instant getDecidedAt()
    • getDecisionComment

      public String getDecisionComment()
    • setStatus

      public void setStatus(RequestStatus status)
      Only the policy services may transition the status.
    • setDecidedAt

      public void setDecidedAt(Instant decidedAt)
    • setDecisionComment

      public void setDecisionComment(String decisionComment)
    • setApprovers

      public void setApprovers(List<String> approvers)
      Only the policy services change the designated set.
    • setDecidedBy

      public void setDecidedBy(String decidedBy)
      Only the policy services record the deciding approver.
    • addApproverChange

      public void addApproverChange(GrantRequest.ApproverChange change)
      Only the policy services record approver changes.
    • setExpiringNotified

      public void setExpiringNotified(boolean expiringNotified)
      Only the policy services mark the D-36 EXPIRING notification as sent.