Class: Etcdv3::Auth

Inherits:
Object show all
Includes:
GRPC::Core::TimeConsts
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb

Constant Summary collapse

PERMISSIONS =
{
  :read => Authpb::Permission::Type::READ,
  :write => Authpb::Permission::Type::WRITE,
  :readwrite => Authpb::Permission::Type::READWRITE
}

Instance Method Summary collapse

Methods included from GRPC::Core::TimeConsts

from_relative_time

Constructor Details

#initialize(hostname, credentials, timeout, metadata = {}) ⇒ Auth

Returns a new instance of Auth.



12
13
14
15
16
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 12

def initialize(hostname, credentials, timeout,  = {})
  @stub = Etcdserverpb::Auth::Stub.new(hostname, credentials)
  @timeout = timeout
  @metadata = 
end

Instance Method Details

#auth_disable(timeout: nil) ⇒ Object



23
24
25
26
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 23

def auth_disable(timeout: nil)
  request = Etcdserverpb::AuthDisableRequest.new
  @stub.auth_disable(request, metadata: @metadata, deadline: deadline(timeout))
end

#auth_enable(timeout: nil) ⇒ Object



18
19
20
21
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 18

def auth_enable(timeout: nil)
  request = Etcdserverpb::AuthEnableRequest.new
  @stub.auth_enable(request, deadline: deadline(timeout))
end

#generate_token(user, password, timeout: nil) ⇒ Object



115
116
117
118
119
120
121
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 115

def generate_token(user, password, timeout: nil)
  request = Etcdserverpb::AuthenticateRequest.new(
    name: user,
    password: password
  )
  @stub.authenticate(request, deadline: deadline(timeout)).token
end

#role_add(name, timeout: nil) ⇒ Object



28
29
30
31
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 28

def role_add(name, timeout: nil)
  request = Etcdserverpb::AuthRoleAddRequest.new(name: name)
  @stub.role_add(request, metadata: @metadata, deadline: deadline(timeout))
end

#role_delete(name, timeout: nil) ⇒ Object



38
39
40
41
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 38

def role_delete(name, timeout: nil)
  request = Etcdserverpb::AuthRoleDeleteRequest.new(role: name)
  @stub.role_delete(request, metadata: @metadata, deadline: deadline(timeout))
end

#role_get(name, timeout: nil) ⇒ Object



33
34
35
36
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 33

def role_get(name, timeout: nil)
  request = Etcdserverpb::AuthRoleGetRequest.new(role: name)
  @stub.role_get(request, metadata: @metadata, deadline: deadline(timeout))
end

#role_grant_permission(name, permission, key, range_end, timeout: nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 43

def role_grant_permission(name, permission, key, range_end, timeout: nil)
  permission = Authpb::Permission.new(
    permType: Etcdv3::Auth::PERMISSIONS[permission], key: key, range_end: range_end
  )
  @stub.role_grant_permission(
    Etcdserverpb::AuthRoleGrantPermissionRequest.new(
      name: name,
      perm: permission
    ),
    metadata: @metadata,
    deadline: deadline(timeout)
  )
end

#role_list(timeout: nil) ⇒ Object



69
70
71
72
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 69

def role_list(timeout: nil)
  request = Etcdserverpb::AuthRoleListRequest.new
  @stub.role_list(request, metadata: @metadata, deadline: deadline(timeout))
end

#role_revoke_permission(name, permission, key, range_end, timeout: nil) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 57

def role_revoke_permission(name, permission, key, range_end, timeout: nil)
  @stub.role_revoke_permission(
    Etcdserverpb::AuthRoleRevokePermissionRequest.new(
      role: name,
      key: key,
      range_end: range_end
    ),
    metadata: @metadata,
    deadline: deadline(timeout)
  )
end

#user_add(user, password, timeout: nil) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 79

def user_add(user, password, timeout: nil)
  request = Etcdserverpb::AuthUserAddRequest.new(
    name: user,
    password: password
  )
  @stub.user_add(request, metadata: @metadata, deadline: deadline(timeout))
end

#user_change_password(user, new_password, timeout: nil) ⇒ Object



97
98
99
100
101
102
103
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 97

def user_change_password(user, new_password, timeout: nil)
  request = Etcdserverpb::AuthUserChangePasswordRequest.new(
    name: user,
    password: new_password
  )
  @stub.user_change_password(request, metadata: @metadata, deadline: deadline(timeout))
end

#user_delete(user, timeout: nil) ⇒ Object



87
88
89
90
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 87

def user_delete(user, timeout: nil)
  request = Etcdserverpb::AuthUserDeleteRequest.new(name: user)
  @stub.user_delete(request, metadata: @metadata, deadline: deadline(timeout))
end

#user_get(user, timeout: nil) ⇒ Object



92
93
94
95
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 92

def user_get(user, timeout: nil)
  request = Etcdserverpb::AuthUserGetRequest.new(name: user)
  @stub.user_get(request, metadata: @metadata, deadline: deadline(timeout))
end

#user_grant_role(user, role, timeout: nil) ⇒ Object



105
106
107
108
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 105

def user_grant_role(user, role, timeout: nil)
  request = Etcdserverpb::AuthUserGrantRoleRequest.new(user: user, role: role)
  @stub.user_grant_role(request, metadata: @metadata, deadline: deadline(timeout))
end

#user_list(timeout: nil) ⇒ Object



74
75
76
77
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 74

def user_list(timeout: nil)
  request = Etcdserverpb::AuthUserListRequest.new
  @stub.user_list(request, metadata: @metadata, deadline: deadline(timeout))
end

#user_revoke_role(user, role, timeout: nil) ⇒ Object



110
111
112
113
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/auth.rb', line 110

def user_revoke_role(user, role, timeout: nil)
  request = Etcdserverpb::AuthUserRevokeRoleRequest.new(name: user, role: role)
  @stub.user_revoke_role(request, metadata: @metadata, deadline: deadline(timeout))
end