Class: Readiness::SupportSuperFormProcessor::TeamMemberLicense

Inherits:
Client
  • Object
show all
Defined in:
lib/support_readiness/support_super_form_processor/team_member_license.rb

Overview

Defines the class TeamMemberLicense within the module Zendesk.

Author:

  • Jason Colyer

Since:

  • 1.0.42

Class Method Summary collapse

Methods inherited from Client

auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries

Class Method Details

.expirationObject

Sets the global variable expiration

Author:

  • Jason Colyer

Since:

  • 1.0.42



130
131
132
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 130

def self.expiration
  @expiration ||= ENV.fetch('EXPIRATION_DATE')
end

.over_a_year_commentObject

Returns a String used for a comment body

Author:

  • Jason Colyer

Since:

  • 1.0.75



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 45

def self.over_a_year_comment
  <<~STRING
    Greetings @#{requester.username} !

    We have detected the license you are requesting would have an expiration date over the standard allowance of one year.

    To proceed, please take one of the following actions:

    - Comment stating the maximum standard allowance of one year (#{Date.today + 1.years}) is acceptable
    - Comment explaining the reason for an exception to the maximum standard allowance of one year (#{Date.today + 1.years})

    Please note without one of the above actions being done, we would not be able to proceed on this request.

    Thanks!
  STRING
end

.planObject

Sets the global variable plan

Author:

  • Jason Colyer

Since:

  • 1.0.42



94
95
96
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 94

def self.plan
  @plan ||= ENV.fetch('SM_PLAN')
end

.previousObject

Sets the global variable previous

Author:

  • Jason Colyer

Since:

  • 1.0.42



121
122
123
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 121

def self.previous
  @previous ||= ENV.fetch('PREVIOUS_COUNT')
end

.process!(client, admin_client, sandbox = false) ⇒ Object

Process a Team Member License check request

Author:

  • Jason Colyer

Since:

  • 1.0.42



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 18

def self.process!(client, admin_client, sandbox = false)
  @gitlab_client = client
  @gitlab_admin_client = admin_client
  requester
  issue = Readiness::GitLab::Issues.new
  if sandbox
    issue.title = "[SANDBOX REQUEST] GitLab Team Member License request - #{requester.name}"
  else
    issue.title = "GitLab Team Member License request - #{requester.name}"
  end        
  issue.description = team_member_license_message
  create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue)
  puts "Issue created: #{create.web_url}"
  if Date.parse(expiration) > Date.today + 1.years
    comment_params = {
      body: over_a_year_comment
    }
    Readiness::GitLab::Issues.create_comment!(@gitlab_client, project, create, comment_params)
  end
  exit 0
end

.projectObject

Sets the global variable project

Author:

  • Jason Colyer

Since:

  • 1.0.42



85
86
87
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 85

def self.project
  @project ||= Readiness::GitLab::Projects.find!(@gitlab_client, 68534119)
end

.requesterObject

Sets the global variable requester

Author:

  • Jason Colyer

Since:

  • 1.0.42



67
68
69
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 67

def self.requester
  @requester ||= Readiness::SupportSuperFormProcessor::Shared.gitlab_user_check(@gitlab_admin_client, requester_email)
end

.requester_emailObject

Sets the global variable requester_email

Author:

  • Jason Colyer

Since:

  • 1.0.42



76
77
78
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 76

def self.requester_email
  @requester_email ||= ENV.fetch('REQUESTER_EMAIL')
end

.seatsObject

Sets the global variable seats

Author:

  • Jason Colyer

Since:

  • 1.0.42



103
104
105
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 103

def self.seats
  @seats ||= ENV.fetch('SEAT_COUNT')
end

.team_member_license_messageObject

Returns the issue description for a team member license request

Author:

  • Jason Colyer

Since:

  • 1.0.42



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 139

def self.team_member_license_message
  <<~STRING
    # GitLab Team Member License request

    ## Please Note the Following

    - This is for requesting an **internal** self-managed GitLab license. This license should **only** be used by **GitLab team members**.
    - This is solely for **self-managed** GitLab instances. If you are wanting a subscription put on a GitLab.com namespace, please file an AR to IT Ops using the appropriate template.
    - The license can only exist for one year at a time
    - The license will be generated via our cDot **staging** environment only.

    ## Information

    - Name: #{requester.name}
    - Email: #{requester.email}
    - GitLab username: @#{requester.username}
    - License plan: #{plan.capitalize}
    - Number of users: #{seats}
    - True-up count: #{trueup}
    - Previous user count: #{previous}
    - Expiration date: #{expiration}

    ### Support Operations

    * [ ] Follow the directions of the workflow, which can be found [here](https://handbook.gitlab.com/handbook/security/customer-support-operations/docs/team_member_licenses/)

    ---

    /confidential

    /assign @nabeel.bilgrami @avilla4 @secole @rverschoor

    /label ~"Stage::Development" ~administrative ~p4

    /iteration [cadence:"Customer Support Operations"] --current
  STRING
end

.trueupObject

Sets the global variable trueup

Author:

  • Jason Colyer

Since:

  • 1.0.42



112
113
114
# File 'lib/support_readiness/support_super_form_processor/team_member_license.rb', line 112

def self.trueup
  @trueup ||= ENV.fetch('TRUEUP_COUNT')
end