apollo-deploy-signal-sdk 1.0.5

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.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +5 -0
  3. data/LICENSE +21 -0
  4. data/README.md +79 -0
  5. data/docs/README.md +30 -0
  6. data/docs/domains/api-keys.md +92 -0
  7. data/docs/domains/contact-properties.md +122 -0
  8. data/docs/domains/contacts.md +394 -0
  9. data/docs/domains/emails.md +150 -0
  10. data/docs/domains/metrics.md +131 -0
  11. data/docs/domains/projects.md +127 -0
  12. data/docs/domains/segments.md +116 -0
  13. data/docs/domains/sending-domains.md +160 -0
  14. data/docs/domains/suppressions.md +120 -0
  15. data/docs/domains/topics.md +141 -0
  16. data/docs/domains/webhooks.md +200 -0
  17. data/docs/types.md +1225 -0
  18. data/lib/apollo-deploy-signal-sdk.rb +3 -0
  19. data/lib/apollo_deploy_signal_sdk/client.rb +111 -0
  20. data/lib/apollo_deploy_signal_sdk/errors.rb +150 -0
  21. data/lib/apollo_deploy_signal_sdk/resources/api-keys.rb +86 -0
  22. data/lib/apollo_deploy_signal_sdk/resources/contact-properties.rb +108 -0
  23. data/lib/apollo_deploy_signal_sdk/resources/contacts.rb +356 -0
  24. data/lib/apollo_deploy_signal_sdk/resources/emails.rb +128 -0
  25. data/lib/apollo_deploy_signal_sdk/resources/metrics.rb +122 -0
  26. data/lib/apollo_deploy_signal_sdk/resources/projects.rb +114 -0
  27. data/lib/apollo_deploy_signal_sdk/resources/segments.rb +105 -0
  28. data/lib/apollo_deploy_signal_sdk/resources/sending-domains.rb +144 -0
  29. data/lib/apollo_deploy_signal_sdk/resources/suppressions.rb +104 -0
  30. data/lib/apollo_deploy_signal_sdk/resources/topics.rb +126 -0
  31. data/lib/apollo_deploy_signal_sdk/resources/webhooks.rb +184 -0
  32. data/lib/apollo_deploy_signal_sdk/transport.rb +618 -0
  33. data/lib/apollo_deploy_signal_sdk/types.rb +4917 -0
  34. data/lib/apollo_deploy_signal_sdk/version.rb +5 -0
  35. data/lib/apollo_deploy_signal_sdk.rb +47 -0
  36. metadata +135 -0
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "apollo_deploy_signal_sdk"
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "transport"
4
+ require_relative "resources/emails"
5
+ require_relative "resources/metrics"
6
+ require_relative "resources/suppressions"
7
+ require_relative "resources/segments"
8
+ require_relative "resources/topics"
9
+ require_relative "resources/contact-properties"
10
+ require_relative "resources/contacts"
11
+ require_relative "resources/webhooks"
12
+ require_relative "resources/api-keys"
13
+ require_relative "resources/projects"
14
+ require_relative "resources/sending-domains"
15
+
16
+ module ApolloDeploySignalSdk
17
+ # Configuration for the Apollo Signal API SDK client.
18
+ class Config
19
+ # @return [String] the base URL for API requests
20
+ attr_accessor :base_url
21
+ # @return [Integer] request timeout in seconds
22
+ attr_accessor :timeout
23
+ # @return [Hash] retry configuration
24
+ attr_accessor :retries
25
+ # @return [Hash] default headers sent with every request
26
+ attr_accessor :default_headers
27
+ # @return [Boolean] whether POST/PATCH requests may be retried without an idempotency key
28
+ attr_accessor :retry_unsafe_requests
29
+
30
+ # @param base_url [String] the base URL for API requests
31
+ # @param timeout [Integer] request timeout in seconds (default: 15)
32
+ # @param retries [Hash] retry configuration
33
+ # @param default_headers [Hash] headers sent with every request
34
+ def initialize(
35
+ base_url: "https://signal.apollodeploy.com",
36
+ timeout: 15,
37
+ retries: { attempts: 3, backoff: 0.4, jitter: true, max_backoff: 30.0 },
38
+ default_headers: {},
39
+ retry_unsafe_requests: false,
40
+ **_
41
+ )
42
+ @base_url = base_url
43
+ @timeout = timeout
44
+ @retries = retries
45
+ @default_headers = default_headers
46
+ @retry_unsafe_requests = retry_unsafe_requests
47
+ end
48
+ end
49
+
50
+ # Main client for the Apollo Signal API API.
51
+ #
52
+ # Provides access to all API domains as instance methods.
53
+ class Client
54
+ # @return [ApolloDeploySignalSdk::Emails]
55
+ attr_reader :emails
56
+ # @return [ApolloDeploySignalSdk::Metrics]
57
+ attr_reader :metrics
58
+ # @return [ApolloDeploySignalSdk::Suppressions]
59
+ attr_reader :suppressions
60
+ # @return [ApolloDeploySignalSdk::Segments]
61
+ attr_reader :segments
62
+ # @return [ApolloDeploySignalSdk::Topics]
63
+ attr_reader :topics
64
+ # @return [ApolloDeploySignalSdk::ContactProperties]
65
+ attr_reader :contactProperties
66
+ # @return [ApolloDeploySignalSdk::Contacts]
67
+ attr_reader :contacts
68
+ # @return [ApolloDeploySignalSdk::Webhooks]
69
+ attr_reader :webhooks
70
+ # @return [ApolloDeploySignalSdk::ApiKeys]
71
+ attr_reader :apiKeys
72
+ # @return [ApolloDeploySignalSdk::Projects]
73
+ attr_reader :projects
74
+ # @return [ApolloDeploySignalSdk::SendingDomains]
75
+ attr_reader :sendingDomains
76
+
77
+ # @return [ApolloDeploySignalSdk::Config] the client configuration
78
+ attr_reader :config
79
+
80
+ # @return [ApolloDeploySignalSdk::Transport] the underlying HTTP transport
81
+ attr_reader :transport
82
+
83
+ # Create a new API client.
84
+ #
85
+ # @param config [ApolloDeploySignalSdk::Config, Hash, nil]
86
+ # Either a Config instance or keyword arguments matching Config#initialize.
87
+ def initialize(config = nil)
88
+ @config = if config.is_a?(Config)
89
+ config
90
+ elsif config.is_a?(Hash)
91
+ Config.new(**config)
92
+ else
93
+ Config.new
94
+ end
95
+
96
+ @transport = Transport.new(@config)
97
+
98
+ @emails = ApolloDeploySignalSdk::Emails.new(@transport)
99
+ @metrics = ApolloDeploySignalSdk::Metrics.new(@transport)
100
+ @suppressions = ApolloDeploySignalSdk::Suppressions.new(@transport)
101
+ @segments = ApolloDeploySignalSdk::Segments.new(@transport)
102
+ @topics = ApolloDeploySignalSdk::Topics.new(@transport)
103
+ @contactProperties = ApolloDeploySignalSdk::ContactProperties.new(@transport)
104
+ @contacts = ApolloDeploySignalSdk::Contacts.new(@transport)
105
+ @webhooks = ApolloDeploySignalSdk::Webhooks.new(@transport)
106
+ @apiKeys = ApolloDeploySignalSdk::ApiKeys.new(@transport)
107
+ @projects = ApolloDeploySignalSdk::Projects.new(@transport)
108
+ @sendingDomains = ApolloDeploySignalSdk::SendingDomains.new(@transport)
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,150 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApolloDeploySignalSdk
4
+ # Structured error raised on API and network failures.
5
+ #
6
+ # Inherits from StandardError and provides structured access to error
7
+ # details including status code, error code, request ID, and convenience
8
+ # methods for common error classifications.
9
+ #
10
+ # @example Basic error handling
11
+ # begin
12
+ # client.users.get_user(id: "123")
13
+ # rescue ApolloDeploySignalSdk::SDKError => e
14
+ # puts "Error #{e.status}: #{e.message} (#{e.code})"
15
+ # puts "Request ID: #{e.request_id}" if e.request_id
16
+ #
17
+ # if e.rate_limited?
18
+ # sleep 1
19
+ # retry
20
+ # end
21
+ #
22
+ # if e.server_error?
23
+ # # Log and alert
24
+ # end
25
+ # end
26
+ class SDKError < StandardError
27
+ # @return [String] machine-readable error code (e.g. "not_found", "rate_limit_exceeded")
28
+ attr_reader :code
29
+
30
+ # @return [Integer] HTTP status code (0 for network errors)
31
+ attr_reader :status
32
+
33
+ # @return [String, nil] unique request identifier from the server
34
+ attr_reader :request_id
35
+
36
+ # @return [String, nil] ISO 8601 timestamp of error occurrence
37
+ attr_reader :timestamp
38
+
39
+ # @return [String, nil] request path that caused the error
40
+ attr_reader :path
41
+
42
+ # @return [String, nil] HTTP method that caused the error
43
+ attr_reader :method
44
+
45
+ # @return [String, nil] helpful hint for resolving the error
46
+ attr_reader :hint
47
+
48
+ # @return [Hash, nil] structured error details
49
+ attr_reader :details
50
+
51
+ # Create a new SDKError.
52
+ #
53
+ # @param message [String] human-readable error message
54
+ # @param status [Integer] HTTP status code (0 for network errors)
55
+ # @param code [String] machine-readable error code
56
+ # @param request_id [String, nil] server-provided request ID
57
+ # @param timestamp [String, nil] error timestamp
58
+ # @param path [String, nil] request path
59
+ # @param method [String, nil] HTTP method
60
+ # @param hint [String, nil] resolution hint
61
+ # @param details [Hash, nil] structured error details
62
+ def initialize(
63
+ message,
64
+ status = 0,
65
+ code = "unknown_error",
66
+ request_id: nil,
67
+ timestamp: nil,
68
+ path: nil,
69
+ method: nil,
70
+ hint: nil,
71
+ details: nil
72
+ )
73
+ super(message)
74
+
75
+ @code = code
76
+ @status = status
77
+ @request_id = request_id
78
+ @timestamp = timestamp
79
+ @path = path
80
+ @method = method
81
+ @hint = hint
82
+ @details = details
83
+ end
84
+
85
+ # @return [Boolean] true if the error is a rate limit (HTTP 429)
86
+ def rate_limited?
87
+ @code == "rate_limit_exceeded" || @status == 429
88
+ end
89
+
90
+ # @return [Boolean] true if the error is authentication-related
91
+ def auth_error?
92
+ %w[unauthorized credential_expired credential_revoked].include?(@code)
93
+ end
94
+
95
+ # @return [Boolean] true if the error is a permission error (HTTP 403)
96
+ def forbidden?
97
+ @code == "forbidden" || @status == 403
98
+ end
99
+
100
+ # @return [Boolean] true if the resource was not found (HTTP 404)
101
+ def not_found?
102
+ @code == "not_found" || @status == 404
103
+ end
104
+
105
+ # @return [Boolean] true if the error is a validation error
106
+ def validation_error?
107
+ %w[validation_failed request_validation_failed bad_request unprocessable_entity].include?(@code) ||
108
+ @status == 422
109
+ end
110
+
111
+ # @return [Boolean] true if status is 5xx (server error)
112
+ def server_error?
113
+ @status >= 500
114
+ end
115
+
116
+ # @return [Boolean] true if status is 4xx (client error)
117
+ def client_error?
118
+ @status >= 400 && @status < 500
119
+ end
120
+
121
+ # @return [Boolean] true if this error is safe to retry
122
+ def retryable?
123
+ @code == "network_error" ||
124
+ @code == "gateway_timeout" ||
125
+ [408, 425, 429].include?(@status) ||
126
+ @status >= 500
127
+ end
128
+
129
+ # @return [Hash] a hash representation for logging and serialization
130
+ def to_h
131
+ {
132
+ name: "SDKError",
133
+ message: message,
134
+ status: @status,
135
+ code: @code,
136
+ request_id: @request_id,
137
+ timestamp: @timestamp,
138
+ path: @path,
139
+ method: @method,
140
+ hint: @hint,
141
+ details: @details
142
+ }.compact
143
+ end
144
+
145
+ # @return [String] JSON representation for logging
146
+ def to_json(*args)
147
+ to_h.to_json(*args)
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../transport"
4
+ require_relative "../errors"
5
+
6
+ module ApolloDeploySignalSdk
7
+ # apiKeys API domain
8
+ class ApiKeys
9
+ attr_reader :transport
10
+
11
+ def initialize(transport)
12
+ @transport = transport
13
+ end
14
+
15
+ # @param project_id [String]
16
+ # @raise [ApolloDeploySignalSdk::SDKError]
17
+ # @return [ListApiKeysResponse]
18
+ def list_api_keys(project_id:)
19
+ path_params = {
20
+ "projectId" => project_id,
21
+ }
22
+
23
+ transport.request(
24
+ method: :get,
25
+ path: "/v1/projects/${projectId}/api-keys",
26
+ path_params: path_params,
27
+ timeout_ms: nil,
28
+ )
29
+ end
30
+
31
+ # @param project_id [String]
32
+ # @param key_id [String]
33
+ # @raise [ApolloDeploySignalSdk::SDKError]
34
+ # @return [ApiKey]
35
+ def get_api_key(project_id:, key_id:)
36
+ path_params = {
37
+ "projectId" => project_id,
38
+ "keyId" => key_id,
39
+ }
40
+
41
+ transport.request(
42
+ method: :get,
43
+ path: "/v1/projects/${projectId}/api-keys/${keyId}",
44
+ path_params: path_params,
45
+ timeout_ms: nil,
46
+ )
47
+ end
48
+
49
+ # @param project_id [String]
50
+ # @param key_id [String]
51
+ # @raise [ApolloDeploySignalSdk::SDKError]
52
+ # @return [ApiKeyUsageResponse]
53
+ def get_api_key_usage(project_id:, key_id:)
54
+ path_params = {
55
+ "projectId" => project_id,
56
+ "keyId" => key_id,
57
+ }
58
+
59
+ transport.request(
60
+ method: :get,
61
+ path: "/v1/projects/${projectId}/api-keys/${keyId}/usage",
62
+ path_params: path_params,
63
+ timeout_ms: nil,
64
+ )
65
+ end
66
+
67
+ # @param project_id [String]
68
+ # @param key_id [String]
69
+ # @raise [ApolloDeploySignalSdk::SDKError]
70
+ # @return [nil]
71
+ def export_api_key_usage(project_id:, key_id:)
72
+ path_params = {
73
+ "projectId" => project_id,
74
+ "keyId" => key_id,
75
+ }
76
+
77
+ transport.request(
78
+ method: :get,
79
+ path: "/v1/projects/${projectId}/api-keys/${keyId}/usage/export",
80
+ path_params: path_params,
81
+ timeout_ms: nil,
82
+ )
83
+ end
84
+
85
+ end
86
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../transport"
4
+ require_relative "../errors"
5
+
6
+ module ApolloDeploySignalSdk
7
+ # contactProperties API domain
8
+ class ContactProperties
9
+ attr_reader :transport
10
+
11
+ def initialize(transport)
12
+ @transport = transport
13
+ end
14
+
15
+ # @param project_id [String]
16
+ # @raise [ApolloDeploySignalSdk::SDKError]
17
+ # @return [ContactPropertyPageResponse]
18
+ def list_contact_properties(project_id:)
19
+ path_params = {
20
+ "projectId" => project_id,
21
+ }
22
+
23
+ transport.request(
24
+ method: :get,
25
+ path: "/v1/projects/${projectId}/contact-properties",
26
+ path_params: path_params,
27
+ timeout_ms: nil,
28
+ )
29
+ end
30
+
31
+ # @param project_id [String]
32
+ # @param property_id [String]
33
+ # @raise [ApolloDeploySignalSdk::SDKError]
34
+ # @return [ContactPropertyResponse]
35
+ def get_contact_property(project_id:, property_id:)
36
+ path_params = {
37
+ "projectId" => project_id,
38
+ "propertyId" => property_id,
39
+ }
40
+
41
+ transport.request(
42
+ method: :get,
43
+ path: "/v1/projects/${projectId}/contact-properties/${propertyId}",
44
+ path_params: path_params,
45
+ timeout_ms: nil,
46
+ )
47
+ end
48
+
49
+ # @param project_id [String]
50
+ # @param body [CreateContactPropertyBody] request body
51
+ # @raise [ApolloDeploySignalSdk::SDKError]
52
+ # @return [ContactPropertyResponse]
53
+ def create_contact_property(project_id:, body:)
54
+ path_params = {
55
+ "projectId" => project_id,
56
+ }
57
+
58
+ transport.request(
59
+ method: :post,
60
+ path: "/v1/projects/${projectId}/contact-properties",
61
+ path_params: path_params,
62
+ body: body,
63
+ content_type: "application/json",
64
+ timeout_ms: nil,
65
+ )
66
+ end
67
+
68
+ # @param project_id [String]
69
+ # @param property_id [String]
70
+ # @param body [UpdateContactPropertyBody] request body
71
+ # @raise [ApolloDeploySignalSdk::SDKError]
72
+ # @return [ContactPropertyResponse]
73
+ def update_contact_property(project_id:, property_id:, body:)
74
+ path_params = {
75
+ "projectId" => project_id,
76
+ "propertyId" => property_id,
77
+ }
78
+
79
+ transport.request(
80
+ method: :patch,
81
+ path: "/v1/projects/${projectId}/contact-properties/${propertyId}",
82
+ path_params: path_params,
83
+ body: body,
84
+ content_type: "application/json",
85
+ timeout_ms: nil,
86
+ )
87
+ end
88
+
89
+ # @param project_id [String]
90
+ # @param property_id [String]
91
+ # @raise [ApolloDeploySignalSdk::SDKError]
92
+ # @return [nil]
93
+ def delete_contact_property(project_id:, property_id:)
94
+ path_params = {
95
+ "projectId" => project_id,
96
+ "propertyId" => property_id,
97
+ }
98
+
99
+ transport.request(
100
+ method: :delete,
101
+ path: "/v1/projects/${projectId}/contact-properties/${propertyId}",
102
+ path_params: path_params,
103
+ timeout_ms: nil,
104
+ )
105
+ end
106
+
107
+ end
108
+ end