Class: ActiveDatastore::Client
- Inherits:
-
Object
- Object
- ActiveDatastore::Client
- Defined in:
- lib/active_datastore/client.rb
Instance Method Summary collapse
- #api ⇒ Object
- #execute(opts) ⇒ Object
-
#initialize(email, secret) ⇒ Client
constructor
A new instance of Client.
- #valid? ⇒ Boolean
Constructor Details
#initialize(email, secret) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/active_datastore/client.rb', line 5 def initialize email, secret @client = Google::APIClient.new key = Google::APIClient::KeyUtils.load_from_pkcs12(secret, 'notasecret') service_account = Google::APIClient::JWTAsserter.new( email, ['https://www.googleapis.com/auth/datastore', 'https://www.googleapis.com/auth/userinfo.email'], key) @client. = service_account. end |
Instance Method Details
#api ⇒ Object
20 21 22 |
# File 'lib/active_datastore/client.rb', line 20 def api @api ||= @client.discovered_api('datastore', 'v1beta1').datasets end |
#execute(opts) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/active_datastore/client.rb', line 24 def execute opts @client.execute({ api_method: api.send(opts[:method]), body_object: opts[:body], parameters: opts[:params] }) end |
#valid? ⇒ Boolean
16 17 18 |
# File 'lib/active_datastore/client.rb', line 16 def valid? not @client..expired? end |