Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Add path_rules to UrlMap #265

Merged
merged 1 commit into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 114 additions & 6 deletions docs/resources/google_compute_url_map.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ Properties that can be accessed from the `google_compute_url_map` resource:

* `description`: An optional description of this resource. Provide this property when you create the resource.

* `path_rules`: The list of path rules.

* `paths`: The list of path patterns to match. Each must start with / and the only place a * is allowed is at the end following a /. The string fed to the path matcher does not include any text after the first ? or #, and those chars are not allowed here.

* `service`: A reference to the BackendService resource if this rule is matched.

* `header_action`: Specifies changes to request and response headers that need to take effect for the selected backendService. HeaderAction specified here are applied after the matching HttpRouteRule HeaderAction and before the HeaderAction in the UrlMap

* `request_headers_to_add`: Headers to add to a matching request prior to forwarding the request to the backendService.
Expand All @@ -108,6 +102,120 @@ Properties that can be accessed from the `google_compute_url_map` resource:

* `name`: The name to which this PathMatcher is referred by the HostRule.

* `path_rules`: The list of path rules. Use this list instead of routeRules when routing based on simple path matching is all that's required. The order by which path rules are specified does not matter. Matches are always done on the longest-path-first basis. For example: a pathRule with a path /a/b/c/* will match before /a/b/* irrespective of the order in which those paths appear in this list. Within a given pathMatcher, only one of pathRules or routeRules must be set.

* `service`: The backend service resource to which traffic is directed if this rule is matched. If routeAction is additionally specified, advanced routing actions like URL Rewrites, etc. take effect prior to sending the request to the backend. However, if service is specified, routeAction cannot contain any weightedBackendService s. Conversely, if routeAction specifies any weightedBackendServices, service must not be specified. Only one of urlRedirect, service or routeAction.weightedBackendService must be set.

* `paths`: The list of path patterns to match. Each must start with / and the only place a * is allowed is at the end following a /. The string fed to the path matcher does not include any text after the first ? or #, and those chars are not allowed here.

* `route_action`: In response to a matching path, the load balancer performs advanced routing actions like URL rewrites, header transformations, etc. prior to forwarding the request to the selected backend. If routeAction specifies any weightedBackendServices, service must not be set. Conversely if service is set, routeAction cannot contain any weightedBackendServices. Only one of routeAction or urlRedirect must be set.

* `cors_policy`: The specification for allowing client side cross-origin requests. Please see W3C Recommendation for Cross Origin Resource Sharing

* `allow_credentials`: In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This translates to the Access- Control-Allow-Credentials header. Defaults to false.

* `allow_headers`: Specifies the content for the Access-Control-Allow-Headers header.

* `allow_methods`: Specifies the content for the Access-Control-Allow-Methods header.

* `allow_origin_regexes`: Specifies the regualar expression patterns that match allowed origins. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript An origin is allowed if it matches either allow_origins or allow_origin_regex.

* `allow_origins`: Specifies the list of origins that will be allowed to do CORS requests. An origin is allowed if it matches either allow_origins or allow_origin_regex.

* `disabled`: If true, specifies the CORS policy is disabled.

* `expose_headers`: Specifies the content for the Access-Control-Expose-Headers header.

* `max_age`: Specifies how long the results of a preflight request can be cached. This translates to the content for the Access-Control-Max-Age header.

* `fault_injection_policy`: The specification for fault injection introduced into traffic to test the resiliency of clients to backend service failure. As part of fault injection, when clients send requests to a backend service, delays can be introduced by Loadbalancer on a percentage of requests before sending those request to the backend service. Similarly requests from clients can be aborted by the Loadbalancer for a percentage of requests. timeout and retry_policy will be ignored by clients that are configured with a fault_injection_policy.

* `abort`: The specification for how client requests are aborted as part of fault injection.

* `http_status`: The HTTP status code used to abort the request. The value must be between 200 and 599 inclusive.

* `percentage`: The percentage of traffic (connections/operations/requests) which will be aborted as part of fault injection. The value must be between 0.0 and 100.0 inclusive.

* `delay`: The specification for how client requests are delayed as part of fault injection, before being sent to a backend service.

* `fixed_delay`: Specifies the value of the fixed delay interval.

* `nanos`: Span of time that's a fraction of a second at nanosecond resolution. Durations less than one second are represented with a 0 `seconds` field and a positive `nanos` field. Must be from 0 to 999,999,999 inclusive.

* `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive.

* `percentage`: The percentage of traffic (connections/operations/requests) on which delay will be introduced as part of fault injection. The value must be between 0.0 and 100.0 inclusive.

* `request_mirror_policy`: Specifies the policy on how requests intended for the route's backends are shadowed to a separate mirrored backend service. Loadbalancer does not wait for responses from the shadow service. Prior to sending traffic to the shadow service, the host / authority header is suffixed with -shadow.

* `backend_service`: The BackendService resource being mirrored to.

* `retry_policy`: Specifies the retry policy associated with this route.

* `num_retries`: Specifies the allowed number retries. This number must be > 0.

* `per_try_timeout`: Specifies a non-zero timeout per retry attempt.

* `nanos`: Span of time that's a fraction of a second at nanosecond resolution. Durations less than one second are represented with a 0 `seconds` field and a positive `nanos` field. Must be from 0 to 999,999,999 inclusive.

* `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive.

* `retry_conditions`: Specfies one or more conditions when this retry rule applies. Valid values are: - 5xx: Loadbalancer will attempt a retry if the backend service responds with any 5xx response code, or if the backend service does not respond at all, example: disconnects, reset, read timeout, connection failure, and refused streams. - gateway-error: Similar to 5xx, but only applies to response codes 502, 503 or 504. - connect-failure: Loadbalancer will retry on failures connecting to backend services, for example due to connection timeouts. - retriable-4xx: Loadbalancer will retry for retriable 4xx response codes. Currently the only retriable error supported is 409. - refused-stream: Loadbalancer will retry if the backend service resets the stream with a REFUSED_STREAM error code. This reset type indicates that it is safe to retry. - cancelled: Loadbalancer will retry if the gRPC status code in the response header is set to cancelled - deadline-exceeded: Loadbalancer will retry if the gRPC status code in the response header is set to deadline-exceeded - resource-exhausted: Loadbalancer will retry if the gRPC status code in the response header is set to resource-exhausted - unavailable: Loadbalancer will retry if the gRPC status code in the response header is set to unavailable

* `timeout`: Specifies the timeout for the selected route. Timeout is computed from the time the request is has been fully processed (i.e. end-of-stream) up until the response has been completely processed. Timeout includes all retries. If not specified, the default value is 15 seconds.

* `nanos`: Span of time that's a fraction of a second at nanosecond resolution. Durations less than one second are represented with a 0 `seconds` field and a positive `nanos` field. Must be from 0 to 999,999,999 inclusive.

* `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive.

* `url_rewrite`: The spec to modify the URL of the request, prior to forwarding the request to the matched service

* `host_rewrite`: Prior to forwarding the request to the selected service, the request's host header is replaced with contents of hostRewrite. The value must be between 1 and 255 characters.

* `path_prefix_rewrite`: Prior to forwarding the request to the selected backend service, the matching portion of the request's path is replaced by pathPrefixRewrite. The value must be between 1 and 1024 characters.

* `weighted_backend_services`: A list of weighted backend services to send traffic to when a route match occurs. The weights determine the fraction of traffic that flows to their corresponding backend service. If all traffic needs to go to a single backend service, there must be one weightedBackendService with weight set to a non 0 number. Once a backendService is identified and before forwarding the request to the backend service, advanced routing actions like Url rewrites and header transformations are applied depending on additional settings specified in this HttpRouteAction.

* `backend_service`: The default BackendService resource. Before forwarding the request to backendService, the loadbalancer applies any relevant headerActions specified as part of this backendServiceWeight.

* `header_action`: Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap.

* `request_headers_to_add`: Headers to add to a matching request prior to forwarding the request to the backendService.

* `header_name`: The name of the header.

* `header_value`: The value of the header to add.

* `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header.

* `request_headers_to_remove`: A list of header names for headers that need to be removed from the request prior to forwarding the request to the backendService.

* `response_headers_to_add`: Headers to add the response prior to sending the response back to the client.

* `header_name`: The name of the header.

* `header_value`: The value of the header to add.

* `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header.

* `response_headers_to_remove`: A list of header names for headers that need to be removed from the response prior to sending the response back to the client.

* `weight`: Specifies the fraction of traffic sent to backendService, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backendService, subsequent requests will be sent to the same backendService as determined by the BackendService's session affinity policy. The value must be between 0 and 1000

* `url_redirect`: When a path pattern is matched, the request is redirected to a URL specified by urlRedirect. If urlRedirect is specified, service or routeAction must not be set.

* `host_redirect`: The host that will be used in the redirect response instead of the one that was supplied in the request. The value must be between 1 and 255 characters.

* `https_redirect`: If set to true, the URL scheme in the redirected request is set to https. If set to false, the URL scheme of the redirected request will remain the same as that of the request. This must only be set for UrlMaps used in TargetHttpProxys. Setting this true for TargetHttpsProxy is not permitted. Defaults to false.

* `path_redirect`: The path that will be used in the redirect response instead of the one that was supplied in the request. Only one of pathRedirect or prefixRedirect must be specified. The value must be between 1 and 1024 characters.

* `prefix_redirect`: The prefix that replaces the prefixMatch specified in the HttpRouteRuleMatch, retaining the remaining portion of the URL before redirecting the request.

* `redirect_response_code`: The HTTP Status code to use for this RedirectAction. Supported values are: - MOVED_PERMANENTLY_DEFAULT, which is the default value and corresponds to 301. - FOUND, which corresponds to 302. - SEE_OTHER which corresponds to 303. - TEMPORARY_REDIRECT, which corresponds to 307. In this case, the request method will be retained. - PERMANENT_REDIRECT, which corresponds to 308. In this case, the request method will be retained.

* `strip_query`: If set to true, any accompanying query portion of the original URL is removed prior to redirecting the request. If set to false, the query portion of the original URL is retained.

* `route_rules`: The list of ordered HTTP route rules. Use this list instead of pathRules when advanced route matching and routing actions are desired. The order of specifying routeRules matters: the first rule that matches will cause its specified routing action to take effect. Within a given pathMatcher, only one of pathRules or routeRules must be set. routeRules are not supported in UrlMaps intended for External load balancers.

* `priority`: For routeRules within a given pathMatcher, priority determines the order in which load balancer will interpret routeRules. RouteRules are evaluated in order of priority, from the lowest to highest number. The priority of a rule decreases as its number increases (1, 2, 3, N+1). The first rule that matches the request is applied. You cannot configure two or more routeRules with the same priority. Priority for each rule must be set to a number between 0 and 2147483647 inclusive. Priority numbers can have gaps, which enable you to add or remove rules in the future without affecting the rest of the rules. For example, 1, 2, 3, 4, 5, 9, 12, 16 is a valid series of priority numbers to which you could add rules numbered from 6 to 8, 10 to 11, and 13 to 15 in the future without any impact on existing rules.
Expand Down
6 changes: 3 additions & 3 deletions libraries/google/compute/property/urlmap_path_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ class UrlMapPathMatchers

attr_reader :description

attr_reader :path_rules

attr_reader :header_action

attr_reader :name

attr_reader :path_rules

attr_reader :route_rules

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@default_service = args['defaultService']
@description = args['description']
@path_rules = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesArray.parse(args['pathRules'], to_s)
@header_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersHeaderAction.new(args['headerAction'], to_s)
@name = args['name']
@path_rules = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesArray.parse(args['pathRules'], to_s)
@route_rules = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesArray.parse(args['routeRules'], to_s)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,38 @@
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_cors_policy'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_abort'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay_fixed_delay'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_request_mirror_policy'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy_per_try_timeout'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_timeout'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_url_rewrite'
require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services'
require 'google/compute/property/urlmap_path_matchers_path_rules_url_redirect'
module GoogleInSpec
module Compute
module Property
class UrlMapPathMatchersPathRules
attr_reader :service

attr_reader :paths

attr_reader :service
attr_reader :route_action

attr_reader :url_redirect

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@paths = args['paths']
@service = args['service']
@paths = args['paths']
@route_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteAction.new(args['routeAction'], to_s)
@url_redirect = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesUrlRedirect.new(args['urlRedirect'], to_s)
end

def to_s
Expand Down
Loading