smplkit 3.0.95 → 3.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,178 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Smplkit
4
- module Management
5
- # An environment resource — a customer-defined deploy target (production,
6
- # staging, etc.) for which configs and flags can have overrides.
7
- class Environment
8
- attr_accessor :id, :key, :name, :color, :classification, :description, :created_at, :updated_at
9
-
10
- def initialize(client = nil, key:, id: nil, name: nil, color: nil,
11
- classification: EnvironmentClassification::STANDARD,
12
- description: nil, created_at: nil, updated_at: nil)
13
- @client = client
14
- @id = id
15
- @key = key
16
- @name = name
17
- @color = color
18
- @classification = classification
19
- @description = description
20
- @created_at = created_at
21
- @updated_at = updated_at
22
- end
23
-
24
- def save
25
- raise "Environment was constructed without a client; cannot save" if @client.nil?
26
-
27
- updated =
28
- if @created_at.nil?
29
- @client._create_environment(self)
30
- else
31
- @client._update_environment(self)
32
- end
33
- _apply(updated)
34
- self
35
- end
36
- alias save! save
37
-
38
- def delete
39
- raise "Environment was constructed without a client; cannot delete" if @client.nil?
40
-
41
- @client.delete(@key)
42
- end
43
- alias delete! delete
44
-
45
- def _apply(other)
46
- @id = other.id
47
- @key = other.key
48
- @name = other.name
49
- @color = other.color
50
- @classification = other.classification
51
- @description = other.description
52
- @created_at = other.created_at
53
- @updated_at = other.updated_at
54
- end
55
- end
56
-
57
- # A context type resource (e.g. "user", "account").
58
- class ContextType
59
- attr_accessor :id, :key, :name, :description, :created_at, :updated_at
60
-
61
- def initialize(client = nil, key:, id: nil, name: nil, description: nil,
62
- created_at: nil, updated_at: nil)
63
- @client = client
64
- @id = id
65
- @key = key
66
- @name = name
67
- @description = description
68
- @created_at = created_at
69
- @updated_at = updated_at
70
- end
71
-
72
- def save
73
- raise "ContextType was constructed without a client; cannot save" if @client.nil?
74
-
75
- updated =
76
- if @created_at.nil?
77
- @client._create_context_type(self)
78
- else
79
- @client._update_context_type(self)
80
- end
81
- _apply(updated)
82
- self
83
- end
84
- alias save! save
85
-
86
- def delete
87
- raise "ContextType was constructed without a client; cannot delete" if @client.nil?
88
-
89
- @client.delete(@key)
90
- end
91
- alias delete! delete
92
-
93
- def _apply(other)
94
- @id = other.id
95
- @key = other.key
96
- @name = other.name
97
- @description = other.description
98
- @created_at = other.created_at
99
- @updated_at = other.updated_at
100
- end
101
- end
102
-
103
- # A service resource — a backend application or microservice in the
104
- # customer's stack that contexts can be evaluated against.
105
- class Service
106
- attr_accessor :id, :key, :name, :created_at, :updated_at
107
-
108
- def initialize(client = nil, key:, id: nil, name: nil,
109
- created_at: nil, updated_at: nil)
110
- @client = client
111
- @id = id
112
- @key = key
113
- @name = name
114
- @created_at = created_at
115
- @updated_at = updated_at
116
- end
117
-
118
- def save
119
- raise "Service was constructed without a client; cannot save" if @client.nil?
120
-
121
- updated =
122
- if @created_at.nil?
123
- @client._create_service(self)
124
- else
125
- @client._update_service(self)
126
- end
127
- _apply(updated)
128
- self
129
- end
130
- alias save! save
131
-
132
- def delete
133
- raise "Service was constructed without a client; cannot delete" if @client.nil?
134
-
135
- @client.delete(@key)
136
- end
137
- alias delete! delete
138
-
139
- def _apply(other)
140
- @id = other.id
141
- @key = other.key
142
- @name = other.name
143
- @created_at = other.created_at
144
- @updated_at = other.updated_at
145
- end
146
- end
147
-
148
- # An account-wide settings resource.
149
- class AccountSettings
150
- attr_accessor :id, :environment_order, :default_environment, :updated_at
151
-
152
- def initialize(client = nil, id: nil, environment_order: nil,
153
- default_environment: nil, updated_at: nil)
154
- @client = client
155
- @id = id
156
- @environment_order = environment_order || []
157
- @default_environment = default_environment
158
- @updated_at = updated_at
159
- end
160
-
161
- def save
162
- raise "AccountSettings was constructed without a client; cannot save" if @client.nil?
163
-
164
- updated = @client._update_account_settings(self)
165
- _apply(updated)
166
- self
167
- end
168
- alias save! save
169
-
170
- def _apply(other)
171
- @id = other.id
172
- @environment_order = other.environment_order
173
- @default_environment = other.default_environment
174
- @updated_at = other.updated_at
175
- end
176
- end
177
- end
178
- end