Class: Octokit::ManageGHESClient
- Inherits:
-
Object
- Object
- Octokit::ManageGHESClient
- Includes:
- Configurable, Connection, ManageAPI, Warnable
- Defined in:
- lib/octokit/manage_ghes_client.rb,
lib/octokit/manage_ghes_client/manage_ghes.rb
Overview
Client for the Manage GitHub Enterprise Server API
Defined Under Namespace
Modules: ManageAPI
Constant Summary
Constants included from Connection
Connection::CONVENIENCE_HEADERS
Constants included from Authentication
Authentication::FARADAY_BASIC_AUTH_KEYS
Instance Attribute Summary
Attributes included from Configurable
#access_token, #api_endpoint, #auto_paginate, #bearer_token, #client_id, #client_secret, #connection_options, #default_media_type, #login, #manage_ghes_endpoint, #manage_ghes_password, #manage_ghes_username, #management_console_endpoint, #management_console_password, #middleware, #netrc, #netrc_file, #password, #per_page, #proxy, #ssl_verify_mode, #user_agent, #web_endpoint
Instance Method Summary collapse
-
#add_authorized_key(key) ⇒ nil
Add an authorized SSH keys on the Enterprise install.
- #authorized_keys ⇒ Object (also: #get_authorized_keys)
-
#config_status ⇒ nil
(also: #config_check)
Get information about the Enterprise installation.
-
#edit_settings(settings) ⇒ nil
Modify the Enterprise settings.
-
#initialize(options = {}) ⇒ ManageGHESClient
constructor
A new instance of ManageGHESClient.
-
#remove_authorized_key(key) ⇒ nil
(also: #delete_authorized_key)
Removes an authorized SSH keys from the Enterprise install.
-
#settings ⇒ nil
(also: #get_settings)
Get information about the Enterprise installation.
-
#start_configuration ⇒ nil
Start a configuration process.
-
#upload_license(license) ⇒ nil
Uploads a license for the first time.
Methods included from ManageAPI
#maintenance_mode, #set_maintenance_mode
Methods included from Warnable
Methods included from Connection
#agent, #delete, #get, #head, #last_response, #paginate, #patch, #post, #put, #root
Methods included from Authentication
#application_authenticated?, #bearer_authenticated?, #token_authenticated?, #user_authenticated?
Methods included from Configurable
#configure, keys, #netrc?, #reset!, #same_options?
Constructor Details
#initialize(options = {}) ⇒ ManageGHESClient
Returns a new instance of ManageGHESClient.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/octokit/manage_ghes_client.rb', line 21 def initialize( = {}) # Use options passed in, but fall back to module defaults # rubocop:disable Style/HashEachMethods # # This may look like a `.keys.each` which should be replaced with `#each_key`, but # this doesn't actually work, since `#keys` is just a method we've defined ourselves. # The class doesn't fulfill the whole `Enumerable` contract. Octokit::Configurable.keys.each do |key| # rubocop:enable Style/HashEachMethods instance_variable_set(:"@#{key}", [key] || Octokit.instance_variable_get(:"@#{key}")) end end |
Instance Method Details
#add_authorized_key(key) ⇒ nil
Add an authorized SSH keys on the Enterprise install
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/octokit/manage_ghes_client/manage_ghes.rb', line 99 def (key) conn = authenticated_client case key when String if File.exist?(key) key = File.open(key, 'r') content = key.read.strip key.close else content = key end when File content = key.read.strip key.close end queries = {} queries[:key] = content @last_response = conn.post('/manage/v1/access/ssh', queries) end |
#authorized_keys ⇒ Object Also known as:
89 90 91 92 |
# File 'lib/octokit/manage_ghes_client/manage_ghes.rb', line 89 def conn = authenticated_client @last_response = conn.get('/manage/v1/access/ssh') end |
#config_status ⇒ nil Also known as: config_check
Get information about the Enterprise installation
64 65 66 67 |
# File 'lib/octokit/manage_ghes_client/manage_ghes.rb', line 64 def config_status conn = authenticated_client @last_response = conn.get('/manage/v1/config/apply') end |
#edit_settings(settings) ⇒ nil
Modify the Enterprise settings
84 85 86 87 |
# File 'lib/octokit/manage_ghes_client/manage_ghes.rb', line 84 def edit_settings(settings) conn = authenticated_client @last_response = conn.put('/manage/v1/config/settings', settings.to_json.to_s) end |
#remove_authorized_key(key) ⇒ nil Also known as:
Removes an authorized SSH keys from the Enterprise install
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/octokit/manage_ghes_client/manage_ghes.rb', line 124 def (key) conn = authenticated_client case key when String if File.exist?(key) key = File.open(key, 'r') content = key.read.strip key.close else content = key end when File content = key.read.strip key.close end queries = {} queries[:key] = content @last_response = conn.run_request(:delete, '/manage/v1/access/ssh', queries, nil) end |
#settings ⇒ nil Also known as: get_settings
Get information about the Enterprise installation
73 74 75 76 |
# File 'lib/octokit/manage_ghes_client/manage_ghes.rb', line 73 def settings conn = authenticated_client @last_response = conn.get('/manage/v1/config/settings') end |
#start_configuration ⇒ nil
Start a configuration process.
56 57 58 59 |
# File 'lib/octokit/manage_ghes_client/manage_ghes.rb', line 56 def start_configuration conn = authenticated_client @last_response = conn.post('/manage/v1/config/apply') end |
#upload_license(license) ⇒ nil
Uploads a license for the first time
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/octokit/manage_ghes_client/manage_ghes.rb', line 37 def upload_license(license) conn = authenticated_client begin conn.request :multipart rescue Faraday::Error raise Faraday::Error, <<~ERROR The `faraday-multipart` gem is required to upload a license. Please add `gem "faraday-multipart"` to your Gemfile. ERROR end params = {} params[:license] = Faraday::FilePart.new(license, 'binary') params[:password] = @manage_ghes_password @last_response = conn.post('/manage/v1/config/init', params, { 'Content-Type' => 'multipart/form-data' }) end |