class Octokit::EnterpriseManagementConsoleClient

EnterpriseManagementConsoleClient is only meant to be used by GitHub Enterprise Admins and provides access to the management console API endpoints.

@see Octokit::Client Use Octokit::Client for regular API use for GitHub

and GitHub Enterprise.

@see developer.github.com/v3/enterprise-admin/management_console/

Public Class Methods

new(options = {}) click to toggle source
# File lib/octokit/enterprise_management_console_client.rb, line 21
def initialize(options = {})
  # 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}", options[key] || Octokit.instance_variable_get(:"@#{key}"))
  end
end

Protected Instance Methods

endpoint() click to toggle source
# File lib/octokit/enterprise_management_console_client.rb, line 36
def endpoint
  management_console_endpoint
end
management_console_endpoint=(value) click to toggle source

Set Enterprise Management Console endpoint

@param value [String] Management console endpoint

# File lib/octokit/enterprise_management_console_client.rb, line 51
def management_console_endpoint=(value)
  reset_agent
  @management_console_endpoint = value
end
management_console_password=(value) click to toggle source

Set Enterprise Management Console password

@param value [String] Management console admin password

# File lib/octokit/enterprise_management_console_client.rb, line 43
def management_console_password=(value)
  reset_agent
  @management_console_password = value
end

Private Instance Methods

faraday_configuration() click to toggle source

We fall back to raw Faraday for handling the licenses because I’m suspicious that Sawyer isn’t handling binary POSTs correctly: github.com/lostisland/sawyer/blob/03fca4c020f465ec42856d0486ec3991859b0aed/lib/sawyer/agent.rb#L85

# File lib/octokit/enterprise_management_console_client/management_console.rb, line 171
    def faraday_configuration
      @faraday_configuration ||= Faraday.new(url: @management_console_endpoint) do |http|
        http.headers[:user_agent] = user_agent
        begin
          http.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
        http.request :url_encoded

        # Disabling SSL is essential for certain self-hosted Enterprise instances
        if connection_options[:ssl] && !connection_options[:ssl][:verify]
          http.ssl[:verify] = false
        end

        http.use Octokit::Response::RaiseError
        http.adapter Faraday.default_adapter
      end
    end
password_hash() click to toggle source
# File lib/octokit/enterprise_management_console_client/management_console.rb, line 165
def password_hash
  { query: { api_key: @management_console_password } }
end