Class: GoogleDirectory::Connection
- Inherits:
-
Object
- Object
- GoogleDirectory::Connection
- Includes:
- UserCommands, Version
- Defined in:
- lib/google_directory/connection.rb
Overview
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.
The GoogleDirectory, makes it easy to work with Google Directory.
Constant Summary collapse
- CREDENTIALS_PATH =
default settings from google for all users
ENV['CREDENTIALS_JSON_PATH']
- SUB_ACCOUNT =
ENV['SUB_ACCOUNT_NAME']
Constants included from Version
Instance Method Summary collapse
-
#initialize(service: Google::Apis::AdminDirectoryV1::DirectoryService) ⇒ Connection
constructor
A new instance of Connection.
-
#run(command:, attributes: {}) ⇒ Hash
(also: #execute)
Formatted as: ‘{command: :command, attributes: {primary_email: “user@domain”, response: GoogleAnswer} }`.
- #version ⇒ Object
Methods included from UserCommands
#user_change_password, #user_create, #user_delete, #user_exists?, #user_get, #user_reactivate, #user_suspend, #user_update
Constructor Details
#initialize(service: Google::Apis::AdminDirectoryV1::DirectoryService) ⇒ Connection
Note:
make connection to google directory services
Returns a new instance of Connection.
39 40 41 42 |
# File 'lib/google_directory/connection.rb', line 39 def initialize( service: Google::Apis::AdminDirectoryV1::DirectoryService ) @service = service.new @service. = end |
Instance Method Details
#run(command:, attributes: {}) ⇒ Hash Also known as: execute
Returns formatted as: ‘{command: :command, attributes: {primary_email: “user@domain”, response: GoogleAnswer} }`.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/google_directory/connection.rb', line 51 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 |
#version ⇒ Object
44 45 46 |
# File 'lib/google_directory/connection.rb', line 44 def version VERSION end |