Class: Appwrite::Proxy
- Defined in:
- lib/appwrite/services/proxy.rb
Instance Method Summary collapse
-
#create_api_rule(domain:) ⇒ ProxyRule
Create a new proxy rule for serving Appwrite's API on custom domain.
-
#create_function_rule(domain:, function_id:, branch: nil) ⇒ ProxyRule
Create a new proxy rule for executing Appwrite Function on custom domain.
-
#create_redirect_rule(domain:, url:, status_code:, resource_id:, resource_type:) ⇒ ProxyRule
Create a new proxy rule for to redirect from custom domain to another domain.
-
#create_site_rule(domain:, site_id:, branch: nil) ⇒ ProxyRule
Create a new proxy rule for serving Appwrite Site on custom domain.
-
#delete_rule(rule_id:) ⇒ Object
Delete a proxy rule by its unique ID.
-
#get_rule(rule_id:) ⇒ ProxyRule
Get a proxy rule by its unique ID.
-
#initialize(client) ⇒ Proxy
constructor
A new instance of Proxy.
-
#list_rules(queries: nil, total: nil) ⇒ ProxyRuleList
Get a list of all the proxy rules.
-
#update_rule_status(rule_id:) ⇒ ProxyRule
If not succeeded yet, retry verification process of a proxy rule domain.
Constructor Details
#initialize(client) ⇒ Proxy
Returns a new instance of Proxy.
6 7 8 |
# File 'lib/appwrite/services/proxy.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#create_api_rule(domain:) ⇒ ProxyRule
Create a new proxy rule for serving Appwrite's API on custom domain.
Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/appwrite/services/proxy.rb', line 48 def create_api_rule(domain:) api_path = '/proxy/rules/api' if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end api_params = { domain: domain, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, response_type: Models::ProxyRule ) end |
#create_function_rule(domain:, function_id:, branch: nil) ⇒ ProxyRule
Create a new proxy rule for executing Appwrite Function on custom domain.
Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/appwrite/services/proxy.rb', line 85 def create_function_rule(domain:, function_id:, branch: nil) api_path = '/proxy/rules/function' if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end if function_id.nil? raise Appwrite::Exception.new('Missing required parameter: "functionId"') end api_params = { domain: domain, functionId: function_id, branch: branch, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, response_type: Models::ProxyRule ) end |
#create_redirect_rule(domain:, url:, status_code:, resource_id:, resource_type:) ⇒ ProxyRule
Create a new proxy rule for to redirect from custom domain to another domain.
Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/appwrite/services/proxy.rb', line 131 def create_redirect_rule(domain:, url:, status_code:, resource_id:, resource_type:) api_path = '/proxy/rules/redirect' if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end if status_code.nil? raise Appwrite::Exception.new('Missing required parameter: "statusCode"') end if resource_id.nil? raise Appwrite::Exception.new('Missing required parameter: "resourceId"') end if resource_type.nil? raise Appwrite::Exception.new('Missing required parameter: "resourceType"') end api_params = { domain: domain, url: url, statusCode: status_code, resourceId: resource_id, resourceType: resource_type, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, response_type: Models::ProxyRule ) end |
#create_site_rule(domain:, site_id:, branch: nil) ⇒ ProxyRule
Create a new proxy rule for serving Appwrite Site on custom domain.
Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/appwrite/services/proxy.rb', line 188 def create_site_rule(domain:, site_id:, branch: nil) api_path = '/proxy/rules/site' if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end if site_id.nil? raise Appwrite::Exception.new('Missing required parameter: "siteId"') end api_params = { domain: domain, siteId: site_id, branch: branch, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, response_type: Models::ProxyRule ) end |
#delete_rule(rule_id:) ⇒ Object
Delete a proxy rule by its unique ID.
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/appwrite/services/proxy.rb', line 257 def delete_rule(rule_id:) api_path = '/proxy/rules/{ruleId}' .gsub('{ruleId}', rule_id) if rule_id.nil? raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', } @client.call( method: 'DELETE', path: api_path, headers: api_headers, params: api_params, ) end |
#get_rule(rule_id:) ⇒ ProxyRule
Get a proxy rule by its unique ID.
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/appwrite/services/proxy.rb', line 226 def get_rule(rule_id:) api_path = '/proxy/rules/{ruleId}' .gsub('{ruleId}', rule_id) if rule_id.nil? raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::ProxyRule ) end |
#list_rules(queries: nil, total: nil) ⇒ ProxyRuleList
Get a list of all the proxy rules. You can use the query params to filter your results.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/appwrite/services/proxy.rb', line 17 def list_rules(queries: nil, total: nil) api_path = '/proxy/rules' api_params = { queries: queries, total: total, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::ProxyRuleList ) end |
#update_rule_status(rule_id:) ⇒ ProxyRule
If not succeeded yet, retry verification process of a proxy rule domain. This endpoint triggers domain verification by checking DNS records. If verification is successful, a TLS certificate will be automatically provisioned for the domain asynchronously in the background.
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/appwrite/services/proxy.rb', line 290 def update_rule_status(rule_id:) api_path = '/proxy/rules/{ruleId}/status' .gsub('{ruleId}', rule_id) if rule_id.nil? raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end api_params = { } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PATCH', path: api_path, headers: api_headers, params: api_params, response_type: Models::ProxyRule ) end |