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_invalidation(domain:, type:, reference: nil) ⇒ ProxyInvalidation
Create a new CDN cache invalidation for a 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.
-
#create_smtp_rule(domain:, function_id:, branch: nil) ⇒ ProxyRule
Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email.
-
#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_function_rule(rule_id:, function_id:, branch: nil) ⇒ ProxyRule
Update the function and VCS branch a function proxy rule executes.
-
#update_redirect_rule(rule_id:, url:, status_code:, resource_id:, resource_type:) ⇒ ProxyRule
Update the target URL, status code and parent resource of a redirect proxy rule.
-
#update_rule_status(rule_id:) ⇒ ProxyRule
If not succeeded yet, retry verification process of a proxy rule domain.
-
#update_site_rule(rule_id:, site_id:, branch: nil) ⇒ ProxyRule
Update the site and VCS branch a site proxy rule serves.
Constructor Details
#initialize(client) ⇒ Proxy
Returns a new instance of Proxy.
5 6 7 |
# File 'lib/appwrite/services/proxy.rb', line 5 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.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/appwrite/services/proxy.rb', line 98 def create_api_rule( domain: ) if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end api_path = '/proxy/rules/api' 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.
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 |
# File 'lib/appwrite/services/proxy.rb', line 136 def create_function_rule( domain:, function_id:, branch: nil ) 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_path = '/proxy/rules/function' 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_invalidation(domain:, type:, reference: nil) ⇒ ProxyInvalidation
Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content.
Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain.
Domains that route to a function do not support cache invalidation.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/appwrite/services/proxy.rb', line 22 def create_invalidation( domain:, type:, reference: nil ) if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end api_path = '/proxy/invalidations' api_params = { domain: domain, type: type, reference: reference, } 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::ProxyInvalidation ) 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.
185 186 187 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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/appwrite/services/proxy.rb', line 185 def create_redirect_rule( domain:, url:, status_code:, resource_id:, resource_type: ) 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_path = '/proxy/rules/redirect' 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.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/appwrite/services/proxy.rb', line 247 def create_site_rule( domain:, site_id:, branch: nil ) 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_path = '/proxy/rules/site' 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 |
#create_smtp_rule(domain:, function_id:, branch: nil) ⇒ ProxyRule
Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email.
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 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/appwrite/services/proxy.rb', line 291 def create_smtp_rule( domain:, function_id:, branch: nil ) 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_path = '/proxy/rules/smtp' 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 |
#delete_rule(rule_id:) ⇒ Object
Delete a proxy rule by its unique ID.
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/appwrite/services/proxy.rb', line 363 def delete_rule( rule_id: ) if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end api_path = '/proxy/rules/{ruleId}' .gsub('{ruleId}', @client.encode_path(rule_id)) api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": '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.
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/appwrite/services/proxy.rb', line 332 def get_rule( rule_id: ) if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end api_path = '/proxy/rules/{ruleId}' .gsub('{ruleId}', @client.encode_path(rule_id)) 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.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/appwrite/services/proxy.rb', line 65 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_function_rule(rule_id:, function_id:, branch: nil) ⇒ ProxyRule
Update the function and VCS branch a function proxy rule executes. The rule domain cannot be changed.
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File 'lib/appwrite/services/proxy.rb', line 397 def update_function_rule( rule_id:, function_id:, branch: nil ) if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end if function_id.nil? raise Appwrite::Exception.new('Missing required parameter: "functionId"') end api_path = '/proxy/rules/{ruleId}/function' .gsub('{ruleId}', @client.encode_path(rule_id)) api_params = { functionId: function_id, branch: branch, } 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 |
#update_redirect_rule(rule_id:, url:, status_code:, resource_id:, resource_type:) ⇒ ProxyRule
Update the target URL, status code and parent resource of a redirect proxy rule. The rule domain cannot be changed.
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/appwrite/services/proxy.rb', line 443 def update_redirect_rule( rule_id:, url:, status_code:, resource_id:, resource_type: ) if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') 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_path = '/proxy/rules/{ruleId}/redirect' .gsub('{ruleId}', @client.encode_path(rule_id)) api_params = { 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: 'PATCH', path: api_path, headers: api_headers, params: api_params, response_type: Models::ProxyRule ) 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. A verified rule whose certificate renewal failed or is blocked, or whose certificate expired, is checked the same way, and its certificate renewed in the background.
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
# File 'lib/appwrite/services/proxy.rb', line 550 def update_rule_status( rule_id: ) if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end api_path = '/proxy/rules/{ruleId}/status' .gsub('{ruleId}', @client.encode_path(rule_id)) 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 |
#update_site_rule(rule_id:, site_id:, branch: nil) ⇒ ProxyRule
Update the site and VCS branch a site proxy rule serves. The rule domain cannot be changed.
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
# File 'lib/appwrite/services/proxy.rb', line 503 def update_site_rule( rule_id:, site_id:, branch: nil ) if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end if site_id.nil? raise Appwrite::Exception.new('Missing required parameter: "siteId"') end api_path = '/proxy/rules/{ruleId}/site' .gsub('{ruleId}', @client.encode_path(rule_id)) api_params = { siteId: site_id, branch: branch, } 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 |