Class: SupportOps::GitLab::ProjectAccessTokens
- Defined in:
- lib/support_ops_gitlab/gitlab/project_access_tokens.rb
Overview
Get details on a project access token => docs.gitlab.com/api/project_access_tokens/#get-details-on-a-project-access-token
Defines the class ProjectAccessTokens within the module SupportOps::GitLab.
Instance Attribute Summary collapse
-
#access_level ⇒ Integer
Role for the token; possible values: 10 (Guest), 15 (Planner), 20 (Reporter), 30 (Developer), 40 (Maintainer), and 50 (Owner).
-
#active ⇒ Boolean
If the token is active or not.
-
#created_at ⇒ String
The timestamp the token was created at.
-
#description ⇒ String
The description of the token.
-
#expires_at ⇒ String
Expiration date of the token in ISO format (YYYY-MM-DD).
-
#id ⇒ Integer
The ID of the token.
-
#last_used_at ⇒ String
The timestamp the token was last used.
-
#name ⇒ String
The name of the token.
-
#project_id ⇒ Integer
The ID of the project the token is attached to.
-
#revoked ⇒ String
If the token is revoked or not.
-
#scopes ⇒ Array
The scopes of the token.
-
#token ⇒ String
The token itself (only shows on create and rotate).
-
#user_id ⇒ Integer
The user who created the token.
Class Method Summary collapse
-
.list(**args) ⇒ Array
List all project access tokens.
Instance Method Summary collapse
-
#revoke! ⇒ Object
Revokes a project access token.
-
#rotate! ⇒ Object
Rotates a project access token.
-
#save! ⇒ Object
Create a project access token.
Methods inherited from Base
#activate!, #approve!, attributes, #badges, #ban!, #block!, client, #client=, #commits, configure, #contributors, #create_support_pin!, #deactivate!, define_attributes, #delete!, #diffs, #disable_2fa!, #discussions, #emails, #encoded_path, #events, #find, #find!, #gpg_keys, #hard_delete!, #impersonations, #initialize, #issues, #jobs, #latest_pipeline, #members, #memberships, #merge_requests, #move!, #notes, #paid?, #pats, #pipeline_variables, #pipelines, #preferences, #projects, readonly_attributes, #reject!, #ssh_keys, #status, #store_original_attributes, #subscribe!, #support_pin, to_hash, #tokens, #unban!, #unblock!, #unsubscribe!, #webhooks
Constructor Details
This class inherits a constructor from SupportOps::GitLab::Base
Instance Attribute Details
#access_level ⇒ Integer
Role for the token; possible values: 10 (Guest), 15 (Planner), 20 (Reporter), 30 (Developer), 40 (Maintainer), and 50 (Owner)
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def access_level @access_level end |
#active ⇒ Boolean
If the token is active or not
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def active @active end |
#created_at ⇒ String
The timestamp the token was created at
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def created_at @created_at end |
#description ⇒ String
The description of the token
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def description @description end |
#expires_at ⇒ String
Expiration date of the token in ISO format (YYYY-MM-DD).
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def expires_at @expires_at end |
#id ⇒ Integer
The ID of the token
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def id @id end |
#last_used_at ⇒ String
The timestamp the token was last used
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def last_used_at @last_used_at end |
#name ⇒ String
The name of the token
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def name @name end |
#project_id ⇒ Integer
The ID of the project the token is attached to
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def project_id @project_id end |
#revoked ⇒ String
If the token is revoked or not
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def revoked @revoked end |
#scopes ⇒ Array
The scopes of the token
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def scopes @scopes end |
#token ⇒ String
The token itself (only shows on create and rotate)
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def token @token end |
#user_id ⇒ Integer
The user who created the token
26 27 28 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 26 def user_id @user_id end |
Class Method Details
.list(**args) ⇒ Array
List all project access tokens
overload list(key: value)
@param created_after [String optional] If defined, returns tokens
created after the specified time
@param created_before [String optional] If defined, returns tokens
created before the specified time
@param expires_after [String optional] If defined, returns tokens that
expire after the specified time
@param expires_before [String optional] If defined, returns tokens
that expire before the specified time
@param last_used_after [String optional] If defined, returns tokens
last used after the specified time
@param last_used_before [String optional] If defined, returns tokens
last used before the specified time
@param project_id [Integer required] The ID of the project to use
@param revoked [Boolean optional] If true, only returns revoked tokens
@param search [String optional] If defined, returns tokens that
include the specified value in the name
@param sort [String optional] If defined, sorts the results by the
specified value; possible values: created_asc, created_desc,
expires_asc, expires_desc, last_used_asc, last_used_desc, name_asc,
name_desc
@param state [String optional] If defined, returns tokens with the
specified state; possible values: active and inactive
@param limit [Integer optional] The limit to the number of users
returned. Default to 0 (i.e. no limit)
#see
https://docs.gitlab.com/api/project_access_tokens/#list-all-project-access-tokens
GitLab API > Projects > Access tokens > List all project access tokens
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 154 def self.list(**args) raise 'You have to provide a project_id' unless args[:project_id] args[:created_after] = nil unless args[:created_after] args[:created_before] = nil unless args[:created_before] args[:expires_after] = nil unless args[:expires_after] args[:expires_before] = nil unless args[:expires_before] args[:last_used_after] = nil unless args[:last_used_after] args[:last_used_before] = nil unless args[:last_used_before] args[:revoked] = nil unless args[:revoked] args[:search] = nil unless args[:search] args[:sort] = nil unless args[:sort] args[:state] = nil unless args[:state] args[:limit] = 0 unless args[:limit] params = '' params += "created_after=#{args[:created_after]}&" unless args[:created_after].nil? params += "created_before=#{args[:created_before]}&" unless args[:created_before].nil? params += "expires_after=#{args[:expires_after]}&" unless args[:expires_after].nil? params += "expires_before=#{args[:expires_before]}&" unless args[:expires_before].nil? params += "last_used_after=#{args[:last_used_after]}&" unless args[:last_used_after].nil? params += "last_used_before=#{args[:last_used_before]}&" unless args[:last_used_before].nil? params += "revoked=#{args[:revoked]}&" unless args[:revoked].nil? params += "search=#{args[:search]}&" unless args[:search].nil? params += "sort=#{args[:sort]}&" unless args[:sort].nil? params += "state=#{args[:state]}&" unless args[:state].nil? array = [] page = 1 loop do response = client.connection.get("projects/#{args[:project_id]}/access_tokens?#{params}&page=#{page}&per_page=100") body = Oj.load(response.body) array += body.map { |p| Projects.new(p) } break if args[:limit].to_i.positive? && array.count >= args[:limit].to_i break if body.count < 100 page += 1 end return array if args[:limit].to_i.zero? array.first(args[:limit].to_i) end |
Instance Method Details
#revoke! ⇒ Object
This is inherited from Base#revoke!
Revokes a project access token
20 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 20 def revoke!; end |
#rotate! ⇒ Object
This is inherited from Base#rotate!
Rotates a project access token
22 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 22 def rotate!; end |
#save! ⇒ Object
This is inherited from Base#save!
Create a project access token
29 |
# File 'lib/support_ops_gitlab/gitlab/project_access_tokens.rb', line 29 def save!; end |