class GoogleDirectory::Connection
The GoogleDirectory
, makes it easy to work with Google Directory. @since 0.1.0
@note Its important to have your oauth setup and its client_secret.json file downloaded in the root directory @note You can also use environment variables to override google defaults as wanted.
Constants
- CLIENT_SECRETS_PATH
Get info the Google Cloud Admin console.cloud.google.com/apis/ or build using: developers.google.com/api-client-library/ruby/guide/aaa_client_secrets
- CREDENTIALS_PATH
- OOB_URI
default settings from google for all users
- SCOPE
Scope options - www.googleapis.com/auth/admin.directory.user developers.google.com/admin-sdk/directory/v1/guides/authorizing
Attributes
# answer = GoogleDirectory
.(command: :user_get, attributes: {primary_email: “btihen@las.ch”}) def self.call(service: Google::Apis::AdminDirectoryV1::DirectoryService,
app_name: nil, command:, attributes: {} ) new(service: service, app_name: app_name). run(command: command, attributes: attributes)
end
Public Class Methods
@note make connection to google directory services @param service [Class] the default is: Google::Apis::AdminDirectoryV1::DirectoryService
# File lib/google_directory/connection.rb, line 41 def initialize( service: Google::Apis::AdminDirectoryV1::DirectoryService ) app_name ||= ENV['APPLICATION_NAME'] || 'google_cloud_app_name' @service = service.new @service.client_options.application_name = app_name @service.authorization = authorize end
Public Instance Methods
@note Run a command against Google Directory
@param command [Symbol] choose command to perform these include: :user_get, :user_exists? (t/f), :user_create, :user_delete, :user_update & convience commands :user_suspend, :user_reactivate, :user_change_password @param attributes [Hash] attributes needed to perform command @return [Hash] formatted as: `{success: {command: :command, attributes: {primary_email: “user@domain”}, response: GoogleAnswer} }`
# File lib/google_directory/connection.rb, line 57 def run( command:, attributes: {} ) response = {} begin response = send( command, attributes: attributes ) response[:status] = 'success' rescue Google::Apis::ClientError => error response = {status: 'error', response: error, attributes: attributes, command: command, } end response end
# File lib/google_directory/connection.rb, line 48 def version VERSION end