cartography-api 0.7.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fd800af9e8bd0913f046d0bab7b9f6b2ed94befba22208b42071f6f89d79c90a
4
+ data.tar.gz: 25228b868b185e7981beb12701ddedb0aac075a95309ddabdad4fee135647caf
5
+ SHA512:
6
+ metadata.gz: 3ad6dbedd9029037d3c1a59c02e598762fbd6bfa6f3c5f694c36574f07a376543cbd7ad526eebed663f2452a9735c7f55e7203c75ea79398017a552fd7d57f07
7
+ data.tar.gz: edfcc9e11de37de65d724a300bb319104b78f1ce5ec50026a181b046d6d296ddb6ca0bcb0066a82505423fd81f175e74cd0281220fa060370500653320befa96
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cartography
4
+ class AcceptanceResult
5
+ attr_reader :checks, :summary
6
+
7
+ def initialize(params = {})
8
+ @checks = params["Checks"].map { |c| Check.new(c) }
9
+ @summary = Summary.new(params["Summary"])
10
+ end
11
+
12
+ def success?
13
+ summary.status == "SUCCESS"
14
+ end
15
+
16
+ class Check
17
+ attr_reader :address,
18
+ :dns,
19
+ :duration,
20
+ :error,
21
+ :http,
22
+ :skipped,
23
+ :success
24
+
25
+ def initialize(params = {})
26
+ @address = params["Address"] && Address.new(params["Address"])
27
+ @dns = params["DNS"] && DNS.new(params["DNS"])
28
+ @duration = params["Duration"].to_i
29
+ @error = params["Error"]
30
+ @http = params["HTTP"] && HTTP.new(params["HTTP"])
31
+ @skipped = params["Skipped"]
32
+ @success = params["Success"]
33
+ end
34
+
35
+ class Address
36
+ attr_reader :port,
37
+ :record
38
+
39
+ def initialize(params = {})
40
+ @port = params["Port"].to_i
41
+ @record = params["Record"]
42
+ end
43
+ end
44
+
45
+ class DNS
46
+ attr_reader :record,
47
+ :type
48
+
49
+ def initialize(params = {})
50
+ @record = params["Record"]
51
+ @type = params["Type"]
52
+ end
53
+ end
54
+
55
+ class HTTP
56
+ attr_reader :url
57
+
58
+ def initialize(params = {})
59
+ @url = params["URL"]
60
+ end
61
+ end
62
+ end
63
+
64
+ class Summary
65
+ attr_reader :status, :total_failed, :total_skipped, :total_success
66
+
67
+ def initialize(params = {})
68
+ @status = params["Status"]
69
+ @total_failed = params["TotalFailed"].to_i
70
+ @total_skipped = params["TotalSkipped"].to_i
71
+ @total_success = params["TotalSuccess"].to_i
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,372 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "http"
4
+ require "json"
5
+
6
+ module Cartography
7
+ # Client class is the base method for making calls to the API. Methods
8
+ # either return plain objects or class instances.
9
+ #
10
+ # @attr_reader [String] api_key The API key used for authentication
11
+ # @attr_reader [String] endpoint The API endpoint
12
+ # @attr_reader [Bool] whether to return dynamic data
13
+ # @attr_reader [Integer] the number of retries for the request
14
+ class Client
15
+ attr_reader :username, :password, :endpoint, :dynamic, :retries
16
+
17
+ RETRY_ERRORS = [
18
+ HTTP::ConnectionError,
19
+ HTTP::TimeoutError
20
+ ]
21
+
22
+ def initialize(username:, password:, endpoint:, dynamic: false, retries: 5)
23
+ @username = username
24
+ @password = password
25
+ @endpoint = endpoint
26
+ @dynamic = dynamic
27
+ @retries = retries
28
+ end
29
+
30
+ # Returns true if the endpoint is healthy
31
+ #
32
+ # @return [Bool]
33
+ def ping?
34
+ get_body("ping")["message"] == "pong"
35
+ end
36
+
37
+ # Returns all custom CNAMEs
38
+ #
39
+ # @return [Array<CustomCname>] a list of all custom CNAMEs
40
+ def get_custom_cnames
41
+ cnames = get_body(custom_cnames_root_path)
42
+
43
+ cnames.map do |cname|
44
+ Cartography::CustomCname.new(cname)
45
+ end
46
+ end
47
+
48
+ # Returns all custom cnames associated with the specified account ID
49
+ #
50
+ # @param account_id [String] the account ID
51
+ # @return [Array<CustomCname>] a list of all custom CNAMEs
52
+ def get_custom_cnames_by_account_id(account_id)
53
+ cnames = get_body(custom_cnames_root_path, params: {account_id: account_id})
54
+
55
+ cnames.map do |cname|
56
+ Cartography::CustomCname.new(cname)
57
+ end
58
+ end
59
+
60
+ # Query the API for a custom CNAME
61
+ #
62
+ # @param cname_id [String] the custom CNAME ID
63
+ # @return [Class<CustomCnamey>] a CustomCname instance
64
+ def get_custom_cname(cname_id:)
65
+ params = get_body("#{custom_cnames_root_path}/#{cname_id}")
66
+
67
+ Cartography::CustomCname.new(params)
68
+ end
69
+
70
+ # Perform an acceptance test for a custom CNAME
71
+ #
72
+ # @param cname_id [String] the custom CNAME ID
73
+ # @return [Class<AcceptanceResult>] a AcceptanceResult instance
74
+ def perform_custom_cname_acceptance(cname_id:)
75
+ params = post_body("#{custom_cnames_root_path}/#{cname_id}/acceptance")
76
+
77
+ Cartography::AcceptanceResult.new(params)
78
+ end
79
+
80
+ # Return Goss configuration
81
+ #
82
+ # @param cname_id [String] the custom CNAME ID
83
+ # @param format [String] the format of the result, such as json or yaml
84
+ # @return [String] the Goss configuration
85
+ def get_custom_cname_acceptance_config(cname_id:, format: "json")
86
+ get_body("#{custom_cnames_root_path}/#{cname_id}/acceptance/config", params: {format: format}).to_s
87
+ end
88
+
89
+ # Returns all routing policies
90
+ #
91
+ # @return [Array<RoutingPolicy>] a list of all routing policies
92
+ def get_routing_policies
93
+ policies = get_body(routing_policies_root_path)
94
+
95
+ policies.map do |policy|
96
+ Cartography::RoutingPolicy.new(policy)
97
+ end
98
+ end
99
+
100
+ # Returns all routing policies associated with the specified account ID
101
+ #
102
+ # @param account_id [String] the account ID
103
+ # @return [Array<RoutingPolicy>] a list of all routing policies
104
+ def get_routing_policies_by_account_id(account_id)
105
+ policies = get_body(routing_policies_root_path, params: {account_id: account_id})
106
+
107
+ policies.map do |policy|
108
+ Cartography::RoutingPolicy.new(policy)
109
+ end
110
+ end
111
+
112
+ # Query the API for a routing policy
113
+ #
114
+ # @param policy_id [String] the routing policy ID
115
+ # @return [Class<RoutingPolicy>] a RoutingPolicy instance
116
+ def get_routing_policy(policy_id:)
117
+ params = get_body("#{routing_policies_root_path}/#{policy_id}")
118
+
119
+ Cartography::RoutingPolicy.new(params)
120
+ end
121
+
122
+ # Perform an acceptance test for a routing policy
123
+ #
124
+ # @param policy_id [String] the routing policy ID
125
+ # @return [Class<AcceptanceResult>] a AcceptanceResult instance
126
+ def perform_routing_policy_acceptance(policy_id:)
127
+ params = post_body("#{routing_policies_root_path}/#{policy_id}/acceptance")
128
+
129
+ Cartography::AcceptanceResult.new(params)
130
+ end
131
+
132
+ # Return Goss configuration
133
+ #
134
+ # @param policy_id [String] the routing policy ID
135
+ # @param format [String] the format of the result, such as json or yaml
136
+ # @return [String] the Goss configuration
137
+ def get_routing_policy_acceptance_config(policy_id:, format: "json")
138
+ get_body("#{routing_policies_root_path}/#{policy_id}/acceptance/config", params: {format: format}).to_s
139
+ end
140
+
141
+ # Query the API for all clusters
142
+ #
143
+ # @return [Array<Cluster>]
144
+ def get_clusters
145
+ clusters = get_body(clusters_root_path)
146
+
147
+ clusters.map do |cluster|
148
+ Cartography::Cluster.new(cluster)
149
+ end
150
+ end
151
+
152
+ # Query the API for clusters by type
153
+ #
154
+ # @param type [String] the cluster type, such as realtime
155
+ # @return [Array<Cluster>]
156
+ def get_clusters_by_type(type:)
157
+ clusters = get_body("#{clusters_root_path}/#{type}")
158
+
159
+ clusters.map do |cluster|
160
+ Cartography::Cluster.new(cluster)
161
+ end
162
+ end
163
+
164
+ # Query the API for a specific cluster
165
+ #
166
+ # @param type [String] the cluster type, such as realtime
167
+ # @param namespace [String] the cluster namespace, such as main
168
+ # @return [Array<Cluster>]
169
+ def get_cluster(type:, namespace:)
170
+ cluster = get_body("#{clusters_root_path}/#{type}/#{namespace}")
171
+ Cartography::Cluster.new(cluster)
172
+ end
173
+
174
+ # Perform an acceptance test for a cluster
175
+ #
176
+ # @param type [String] the cluster type, such as realtime
177
+ # @param namespace [String] the cluster namespace, such as main
178
+ # @return [Class<AcceptanceResult>] an AcceptanceResult instance
179
+ def perform_cluster_acceptance(type:, namespace:)
180
+ params = post_body("#{clusters_root_path}/#{type}/#{namespace}/acceptance")
181
+
182
+ Cartography::AcceptanceResult.new(params)
183
+ end
184
+
185
+ # Return Goss configuration for a cluster
186
+ #
187
+ # @param type [String] the cluster type, such as realtime
188
+ # @param namespace [String] the cluster namespace, such as main
189
+ # @param format [String] the format of the result, such as json or yaml
190
+ # @return [String] the Goss configuration
191
+ def get_cluster_acceptance_config(type:, namespace:, format: "json")
192
+ get_body("#{clusters_root_path}/#{type}/#{namespace}/acceptance/config", params: {format: format}).to_s
193
+ end
194
+
195
+ # Query the API for a specific cluster site by type, namespace and site
196
+ #
197
+ # @param type [String] the cluster type, such as realtime
198
+ # @param namespace [String] the cluster namespace, such as main
199
+ # @param site [String] the cluster site, such as eu-west-1-A
200
+ # @return [Cluster]
201
+ def get_cluster_site(type:, namespace:, site:)
202
+ site = get_body("#{clusters_root_path}/#{type}/#{namespace}/#{site}")
203
+ Cartography::Cluster::Site.new(site)
204
+ end
205
+
206
+ # Perform an acceptance test for a cluster site
207
+ #
208
+ # @param type [String] the cluster type, such as realtime
209
+ # @param namespace [String] the cluster namespace, such as main
210
+ # @param site [String] the cluster site, such as eu-west-1-A
211
+ # @return [Class<AcceptanceResult>] an AcceptanceResult instance
212
+ def perform_cluster_site_acceptance(type:, namespace:, site:)
213
+ params = post_body("#{clusters_root_path}/#{type}/#{namespace}/#{site}/acceptance")
214
+
215
+ Cartography::AcceptanceResult.new(params)
216
+ end
217
+
218
+ # Return Goss configuration for a cluster site
219
+ #
220
+ # @param type [String] the cluster type, such as realtime
221
+ # @param namespace [String] the cluster namespace, such as main
222
+ # @param site [String] the cluster site, such as eu-west-1-A
223
+ # @param format [String] the format of the result, such as json or yaml
224
+ # @return [String] the Goss configuration
225
+ def get_cluster_site_acceptance_config(type:, namespace:, site:, format: "json")
226
+ get_body("#{clusters_root_path}/#{type}/#{namespace}/#{site}/acceptance/config", params: {format: format}).to_s
227
+ end
228
+
229
+ # Query the API for all server groups in a specific cluster site by type,
230
+ # namespace and site
231
+ #
232
+ # @param type [String] the cluster type, such as realtime
233
+ # @param namespace [String] the cluster namespace, such as main
234
+ # @param site [String] the cluster site, such as eu-west-1-A
235
+ # @return [Array<ServerGroup>]
236
+ def get_cluster_site_server_groups(type:, namespace:, site:)
237
+ server_groups = get_body("#{clusters_root_path}/#{type}/#{namespace}/#{site}/server-groups")
238
+
239
+ server_groups.map do |sg|
240
+ Cartography::Cluster::Site::ServerGroup.new(sg)
241
+ end
242
+ end
243
+
244
+ # Query the API for a specific server group in a specific cluster site by
245
+ # type, namespace and site
246
+ #
247
+ # @param type [String] the cluster type, such as realtime
248
+ # @param namespace [String] the cluster namespace, such as main
249
+ # @param site [String] the cluster site, such as eu-west-1-A
250
+ # @param server_group [String] the server group, such as core
251
+ # @return [ServerGroup]
252
+ def get_cluster_site_server_group(type:, namespace:, site:, server_group:)
253
+ server_group = get_body("#{clusters_root_path}/#{type}/#{namespace}/#{site}/server-groups/#{server_group}")
254
+ Cartography::Cluster::Site::ServerGroup.new(server_group)
255
+ end
256
+
257
+ # Returns all placement constraints
258
+ #
259
+ # @return [Array<PlacementConstraint>] a list of all placement constraints
260
+ def get_placement_constraints
261
+ constraints = get_body(placement_constraints_root_path)
262
+
263
+ constraints.map do |constraint|
264
+ Cartography::PlacementConstraint.new(constraint)
265
+ end
266
+ end
267
+
268
+ # Returns all placement constraints associated with the specified account ID
269
+ #
270
+ # @param account_id [String] the account ID
271
+ # @return [Array<PlacementConstraint>] a list of all placement constraints
272
+ def get_placement_constraints_by_account_id(account_id)
273
+ constraints = get_body(placement_constraints_root_path, params: {account_id: account_id})
274
+
275
+ constraints.map do |constraint|
276
+ Cartography::PlacementConstraint.new(constraint)
277
+ end
278
+ end
279
+
280
+ # Query the API for a placement constraint
281
+ #
282
+ # @param placement_constraint_id [String] the placement constraint ID
283
+ # @return [Class<PlacementConstraint>] a PlacementConstraint instance
284
+ def get_placement_constraint(placement_constraint_id:)
285
+ params = get_body("#{placement_constraints_root_path}/#{placement_constraint_id}")
286
+
287
+ Cartography::PlacementConstraint.new(params)
288
+ end
289
+
290
+ class ResponseError < StandardError; end
291
+
292
+ def get(path, params: {})
293
+ retry_count ||= 0
294
+
295
+ resp = HTTP.basic_auth(user: username, pass: password).get("#{endpoint}/#{strip_path(path)}", params: default_params.merge(params))
296
+
297
+ raise ResponseError, resp.status.to_s unless resp.status.success?
298
+
299
+ resp
300
+ rescue *RETRY_ERRORS => e
301
+ sleep 1 * retry_count
302
+ retry if (retry_count += 1) < retries
303
+
304
+ raise e
305
+ end
306
+
307
+ def get_body(path, params: {})
308
+ JSON.parse(get(path, params: default_params.merge(params || {})).body)
309
+ end
310
+
311
+ def post(path, params: {})
312
+ resp = HTTP.basic_auth(user: username, pass: password).post("#{endpoint}/#{path}", params: default_params.merge(params))
313
+
314
+ raise ResponseError, resp.status.to_s unless resp.status.success?
315
+
316
+ resp
317
+ end
318
+
319
+ def post_body(path, params: {})
320
+ JSON.parse(post(path, params: default_params.merge(params)).body)
321
+ end
322
+
323
+ private
324
+
325
+ def default_params
326
+ if dynamic
327
+ {dynamic: dynamic}
328
+ else
329
+ {}
330
+ end
331
+ end
332
+
333
+ def placement_constraints_root_path
334
+ "placement-constraints"
335
+ end
336
+
337
+ def custom_cnames_root_path
338
+ "custom-cnames"
339
+ end
340
+
341
+ def routing_policies_root_path
342
+ "routing-policies"
343
+ end
344
+
345
+ def clusters_root_path
346
+ "clusters"
347
+ end
348
+
349
+ class InvalidClusterID < StandardError; end
350
+
351
+ def split_cluster_id(cluster_id:)
352
+ split_id = cluster_id.split(":")
353
+
354
+ raise InvalidClusterID if split_id.length != 3
355
+
356
+ {
357
+ environment: split_id.first,
358
+ type: split_id[1],
359
+ namespace: split_id.last
360
+ }
361
+ end
362
+
363
+ # Removes the leading / character
364
+ def strip_path(path)
365
+ if path.match?(/^\/.*$/)
366
+ path[1..]
367
+ else
368
+ path
369
+ end
370
+ end
371
+ end
372
+ end
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cartography
4
+ class Cluster
5
+ attr_reader :cluster_id,
6
+ :environment,
7
+ :type,
8
+ :namespace,
9
+ :site_list,
10
+ :sites,
11
+ :endpoints
12
+
13
+ def initialize(params = {})
14
+ @cluster_id = params["ClusterID"]
15
+ @environment = params["Environment"]
16
+ @type = params["Type"]
17
+ @namespace = params["Namespace"]
18
+ @site_list = params["SiteList"]
19
+ @sites = params["Sites"].map { |s| Site.new(s) }
20
+ @endpoints = Endpoints.new(params["Endpoints"])
21
+ end
22
+
23
+ class Endpoints
24
+ attr_reader :primary,
25
+ :direct_fallback,
26
+ :latency_fallback,
27
+ :internal_api
28
+
29
+ def initialize(params = {})
30
+ @primary = params&.fetch("Primary")
31
+ @direct_fallback = params&.fetch("DirectFallback")
32
+ @latency_fallback = params&.fetch("LatencyFallback")
33
+ @internal_api = params&.fetch("InternalAPI")
34
+ end
35
+ end
36
+
37
+ class Site
38
+ attr_reader :cluster_id,
39
+ :environment,
40
+ :type,
41
+ :namespace,
42
+ :site,
43
+ :site_groups,
44
+ :region,
45
+ :server_groups,
46
+ :load_balancers,
47
+ :zone_assignment,
48
+ :availability_zone,
49
+ :endpoints
50
+
51
+ def initialize(params = {})
52
+ @site = params["Site"]
53
+ @site_groups = params["SiteGroups"]
54
+ @region = params["Region"]
55
+ @server_groups = params["ServerGroups"].map { |p| ServerGroup.new(p) }
56
+
57
+ @load_balancers = params["LoadBalancers"].each_with_object({}) do |(kind, lbs), hash|
58
+ hash[kind] = lbs.map { |lb| LoadBalancer.new(lb) }
59
+ end
60
+
61
+ @zone_assignment = params["ZoneAssignment"]
62
+ @availability_zone = params["AvailabilityZone"]
63
+ @endpoints = Endpoints.new(params["Endpoints"])
64
+ end
65
+
66
+ class LoadBalancer
67
+ attr_reader :name,
68
+ :arn
69
+
70
+ def initialize(params = {})
71
+ @name = params["Name"]
72
+ @arn = params["arn"]
73
+ end
74
+ end
75
+
76
+ class ServerGroup
77
+ attr_reader :name,
78
+ :full_name,
79
+ :arn,
80
+ :min_size,
81
+ :max_size,
82
+ :launch_templates,
83
+ :desired_size,
84
+ :actual_size
85
+
86
+ def initialize(params = {})
87
+ @name = params["Name"]
88
+ @full_name = params["FullName"]
89
+ @arn = params["Arn"]
90
+ @min_size = params["MinSize"]
91
+ @max_size = params["MaxSize"]
92
+ @launch_templates = params["LaunchTemplates"].map { |p| LaunchTemplate.new(p) }
93
+ @desired_size = params["DesiredSize"]
94
+ @actual_size = params["ActualSize"]
95
+ end
96
+
97
+ class LaunchTemplate
98
+ attr_reader :name,
99
+ :id,
100
+ :image_id,
101
+ :instance_type
102
+
103
+ def initialize(params = {})
104
+ @name = params["Name"]
105
+ @id = params["ID"]
106
+ @image_id = params["ImageID"]
107
+ @instance_type = params["InstanceType"]
108
+ end
109
+ end
110
+ end
111
+
112
+ class Endpoints
113
+ attr_reader :primary,
114
+ :fallback,
115
+ :internal_api
116
+
117
+ def initialize(params = {})
118
+ @primary = params&.fetch("Primary")
119
+ @fallback = params&.fetch("Fallback")
120
+ @internal_api = params&.fetch("InternalAPI")
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cartography
4
+ # CustomCname holds data for the current state of a specific custom
5
+ # CNAME.
6
+ #
7
+ # @attr_reader [String] custom_cname_id The ID of the custom CNAME
8
+ class CustomCname
9
+ attr_reader :custom_cname_id,
10
+ :account_id,
11
+ :site_group,
12
+ :target_cluster,
13
+ :associated_routing_policy,
14
+ :cloudfront_distribution_id,
15
+ :target_record,
16
+ :cname_dns_validated,
17
+ :cloudfront_routing_disabled,
18
+ :aws_shield_enabled,
19
+ :fallbacks,
20
+ :certificate
21
+
22
+ def initialize(params = {})
23
+ @custom_cname_id = params["CustomCnameID"]
24
+ @account_id = params["AccountID"]
25
+ @site_group = params["SiteGroup"]
26
+ @target_cluster = params["TargetCluster"]
27
+ @associated_routing_policy = params["AssociatedRoutingPolicy"]
28
+ @cloudfront_distribution_id = params["CloudfrontDistributionID"]
29
+ @target_record = params["TargetRecord"]
30
+ @cname_dns_validated = params["CnameDNSValidated"]
31
+ @cloudfront_routing_disabled = params["CloudfrontRoutingDisabled"]
32
+ @aws_shield_enabled = params["AWSShieldEnabled"]
33
+ @fallbacks = params["Fallbacks"].map { |f| Fallback.new(f) }
34
+ @certificate = Certificate.new(params["Certificate"])
35
+ end
36
+
37
+ class Fallback
38
+ attr_reader :endpoint, :target
39
+
40
+ def initialize(params = {})
41
+ @endpoint = params["Endpoint"]
42
+ @target = params["Target"]
43
+ end
44
+ end
45
+
46
+ class Certificate
47
+ attr_reader :arn
48
+
49
+ def initialize(params = {})
50
+ @arn = params["Arn"]
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cartography
4
+ # PlacementConstraint holds data for the current state of a specific
5
+ # placement constraint.
6
+ class PlacementConstraint
7
+ attr_reader :placement_constraint_id,
8
+ :account_id,
9
+ :cluster,
10
+ :environment,
11
+ :keyspace,
12
+ :placement_error,
13
+ :sites
14
+
15
+ def initialize(params = {})
16
+ @placement_constraint_id = params["PlacementConstraintID"]
17
+ @account_id = params["AccountID"]
18
+ @cluster = params["Cluster"]
19
+ @environment = params["Environment"]
20
+ @keyspace = params["Keyspace"]
21
+ @placement_error = PlacementError.new(params["PlacementError"])
22
+ @sites = params["Sites"]
23
+ end
24
+
25
+ class PlacementError
26
+ attr_reader :status_code
27
+
28
+ def initialize(params = {})
29
+ @status_code = params["StatusCode"]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cartography
4
+ # RoutingPolicy holds data for the current state of a specific routing
5
+ # policy.
6
+ #
7
+ # @attr_reader [String] policy_id The ID of the routing policy
8
+ class RoutingPolicy
9
+ attr_reader :policy_id,
10
+ :account_id,
11
+ :protocols,
12
+ :site_group,
13
+ :target_cluster,
14
+ :fallbacks,
15
+ :certificate
16
+
17
+ def initialize(params = {})
18
+ @policy_id = params["PolicyID"]
19
+ @account_id = params["AccountID"]
20
+ @site_group = params["SiteGroup"]
21
+ @target_cluster = params["TargetCluster"]
22
+ @protocols = params["Protocols"].map { |p| Protocol.new(p) }
23
+ @fallbacks = params["Fallbacks"].map { |f| Fallback.new(f) }
24
+ @certificate = Certificate.new(params["Certificate"])
25
+ end
26
+
27
+ class Protocol
28
+ attr_reader :name, :endpoint, :cloudfront_enabled
29
+
30
+ def initialize(params = {})
31
+ @name = params["Name"]
32
+ @endpoint = params["Endpoint"]
33
+ @cloudfront_enabled = params["CloudFrontEnabled"]
34
+ end
35
+ end
36
+
37
+ class Fallback
38
+ attr_reader :endpoint, :target
39
+
40
+ def initialize(params = {})
41
+ @endpoint = params["Endpoint"]
42
+ @target = params["Target"]
43
+ end
44
+ end
45
+
46
+ class Certificate
47
+ attr_reader :arn, :domains
48
+
49
+ def initialize(params = {})
50
+ @arn = params["Arn"]
51
+ @domains = params["Domains"]
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cartography
4
+ VERSION = "0.7.0"
5
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "cartography/acceptance"
4
+ require_relative "cartography/client"
5
+ require_relative "cartography/cluster"
6
+ require_relative "cartography/placement_constraint"
7
+ require_relative "cartography/routing_policy"
8
+ require_relative "cartography/custom_cname"
9
+ require_relative "cartography/version"
10
+
11
+ # The Cartography API is used for querying the current state of our
12
+ # infrastructure.
13
+ #
14
+ # Currently only routing policies are supported.
15
+ module Cartography
16
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cartography-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
5
+ platform: ruby
6
+ authors:
7
+ - Laura Martin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-04-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.4'
27
+ description:
28
+ email:
29
+ - laura.martin@ably.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/cartography.rb
35
+ - lib/cartography/acceptance.rb
36
+ - lib/cartography/client.rb
37
+ - lib/cartography/cluster.rb
38
+ - lib/cartography/custom_cname.rb
39
+ - lib/cartography/placement_constraint.rb
40
+ - lib/cartography/routing_policy.rb
41
+ - lib/cartography/version.rb
42
+ homepage:
43
+ licenses:
44
+ - Apache-2.0
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.7.7
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.2.32
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Query the Cartography API.
65
+ test_files: []