Class: Pgai::Resources::Remote::Clone
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseRecord
client, #client, client=, with_client
Methods included from Attributes
#assign_attribute, #assign_attributes, #has_attribute?, included, #initialize
Instance Attribute Details
#db_object ⇒ Object
Returns the value of attribute db_object.
12
13
14
|
# File 'lib/pgai/resources/remote/clone.rb', line 12
def db_object
@db_object
end
|
Returns the value of attribute metadata.
15
16
17
|
# File 'lib/pgai/resources/remote/clone.rb', line 15
def metadata
@metadata
end
|
#snapshot ⇒ Object
Returns the value of attribute snapshot.
13
14
15
|
# File 'lib/pgai/resources/remote/clone.rb', line 13
def snapshot
@snapshot
end
|
#status ⇒ Object
Returns the value of attribute status.
14
15
16
|
# File 'lib/pgai/resources/remote/clone.rb', line 14
def status
@status
end
|
Class Method Details
.find(id) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/pgai/resources/remote/clone.rb', line 18
def find(id)
data = client.get(File.join(path, id))
raise Pgai::ResourceNotFound unless data.key?(:id)
new(data.slice(:id, :protected)) do |resource|
resource.refresh_attributes(data)
end
end
|
.path ⇒ Object
27
28
29
|
# File 'lib/pgai/resources/remote/clone.rb', line 27
def path
"clone"
end
|
Instance Method Details
#delete ⇒ Object
65
66
67
68
69
70
|
# File 'lib/pgai/resources/remote/clone.rb', line 65
def delete
data = client.delete(object_path)
refresh_attributes(data) unless data.empty?
self
end
|
#ready? ⇒ Boolean
52
53
54
|
# File 'lib/pgai/resources/remote/clone.rb', line 52
def ready?
status.code == "OK"
end
|
#refresh ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/pgai/resources/remote/clone.rb', line 56
def refresh
data = client.get(object_path)
raise Pgai::ResourceNotFound unless data.key?(:id)
refresh_attributes(data)
self
end
|
#refresh_attributes(data) ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/pgai/resources/remote/clone.rb', line 78
def refresh_attributes(data)
assign_attributes(data.slice(:delete_at, :created_at))
ensure_metadata.refresh_attributes(data.fetch(:metadata))
ensure_status.refresh_attributes(data.fetch(:status))
ensure_db_object.refresh_attributes(data.fetch(:db))
ensure_snapshot.refresh_attributes(data.fetch(:snapshot))
end
|
#reset ⇒ Object
72
73
74
75
76
|
# File 'lib/pgai/resources/remote/clone.rb', line 72
def reset
client.post(object_path("reset"))
self
end
|
#save ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/pgai/resources/remote/clone.rb', line 32
def save
body = {
id: id,
snapshot: {
id: snapshot.id
},
protected: protected,
db: {
username: db_object.username,
password: db_object.password,
restricted: db_object.restricted
}
}
data = client.post(self.class.path, body)
refresh_attributes(data)
self
end
|
#status_message ⇒ Object
86
87
88
|
# File 'lib/pgai/resources/remote/clone.rb', line 86
def status_message
status&.message
end
|