Skip to content

Commit

Permalink
Add route_rules to UrlMap for Traffic Director
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
Ty Larrabee authored and modular-magician committed Nov 25, 2019
1 parent 35af2e0 commit 5d133c3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions docs/resources/google_compute_url_map.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,49 +30,49 @@ end
Properties that can be accessed from the `google_compute_url_map` resource:


* `id`: The unique identifier for the resource.

* `creation_timestamp`: Creation timestamp in RFC3339 text format.

* `default_service`: A reference to BackendService resource if none of the hostRules match.
* `default_service`: The BackendService resource to which traffic is directed if none of the hostRules match. If defaultRouteAction is additionally specified, advanced routing actions like URL Rewrites, etc. take effect prior to sending the request to the backend. However, if defaultService is specified, defaultRouteAction cannot contain any weightedBackendServices. Conversely, if routeAction specifies any weightedBackendServices, service must not be specified. Only one of defaultService, defaultUrlRedirect or defaultRouteAction.weightedBackendService must be set.

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

* `fingerprint`: Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking.

* `host_rules`: The list of HostRules to use against the URL.

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

* `hosts`: The list of host patterns to match. They must be valid hostnames, except * will match any string of ([a-z0-9-.]*). In that case, * must be the first character and must be followed in the pattern by either - or ..

* `path_matcher`: The name of the PathMatcher to use to match the path portion of the URL if the hostRule matches the URL's host portion.

* `id`: The unique identifier for the resource.

* `fingerprint`: Fingerprint of this resource. This field is used internally during updates of this resource.

* `name`: Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

* `path_matchers`: The list of named PathMatchers to use against the URL.

* `default_service`: A reference to a BackendService resource. This will be used if none of the pathRules defined by this PathMatcher is matched by the URL's path portion.

* `description`: An optional description of this resource.
* `default_service`: The BackendService resource. This will be used if none of the pathRules or routeRules defined by this PathMatcher are matched. For example, the following are all valid URLs to a BackendService resource: - http s://www.googleapis.com/compute/v1/projects/project/global/backendServices/backen dService - compute/v1/projects/project/global/backendServices/backendService - global/backendServices/backendService If defaultRouteAction is additionally specified, advanced routing actions like URL Rewrites, etc. take effect prior to sending the request to the backend. However, if defaultService is specified, defaultRouteAction cannot contain any weightedBackendServices. Conversely, if defaultRouteAction specifies any weightedBackendServices, defaultService must not be specified. Only one of defaultService, defaultUrlRedirect or defaultRouteAction.weightedBackendService must be set. Authorization requires one or more of the following Google IAM permissions on the specified resource default_service: - compute.backendBuckets.use - compute.backendServices.use

* `name`: The name to which this PathMatcher is referred by the HostRule.
* `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.

* `tests`: The list of expected URL mappings. Requests to update this UrlMap will succeed only if all of the test cases pass.
* `name`: The name to which this PathMatcher is referred by the HostRule.

* `tests`: The list of expected URL mapping tests. Request to update this UrlMap will succeed only if all of the test cases pass. You can specify a maximum of 100 tests per UrlMap.

* `description`: Description of this test case.

* `host`: Host portion of the URL.

* `path`: Path portion of the URL.

* `service`: A reference to expected BackendService resource the given URL should be mapped to.
* `service`: Expected BackendService resource the given URL should be mapped to.


## GCP Permissions
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/google_compute_url_maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ end
Properties that can be accessed from the `google_compute_url_maps` resource:

See [google_compute_url_map.md](google_compute_url_map.md) for more detailed information
* `ids`: an array of `google_compute_url_map` id
* `creation_timestamps`: an array of `google_compute_url_map` creation_timestamp
* `default_services`: an array of `google_compute_url_map` default_service
* `descriptions`: an array of `google_compute_url_map` description
* `host_rules`: an array of `google_compute_url_map` host_rules
* `ids`: an array of `google_compute_url_map` id
* `fingerprints`: an array of `google_compute_url_map` fingerprint
* `host_rules`: an array of `google_compute_url_map` host_rules
* `names`: an array of `google_compute_url_map` name
* `path_matchers`: an array of `google_compute_url_map` path_matchers
* `tests`: an array of `google_compute_url_map` tests
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 @@ -22,17 +22,17 @@ class UrlMapPathMatchers

attr_reader :description

attr_reader :name

attr_reader :path_rules

attr_reader :name

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

def to_s
Expand Down
8 changes: 4 additions & 4 deletions libraries/google_compute_url_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class ComputeUrlMap < GcpResourceBase
supports platform: 'gcp'

attr_reader :params
attr_reader :id
attr_reader :creation_timestamp
attr_reader :default_service
attr_reader :description
attr_reader :host_rules
attr_reader :id
attr_reader :fingerprint
attr_reader :host_rules
attr_reader :name
attr_reader :path_matchers
attr_reader :tests
Expand All @@ -43,12 +43,12 @@ def initialize(params)
end

def parse
@id = @fetched['id']
@creation_timestamp = parse_time_string(@fetched['creationTimestamp'])
@default_service = @fetched['defaultService']
@description = @fetched['description']
@host_rules = GoogleInSpec::Compute::Property::UrlMapHostRulesArray.parse(@fetched['hostRules'], to_s)
@id = @fetched['id']
@fingerprint = @fetched['fingerprint']
@host_rules = GoogleInSpec::Compute::Property::UrlMapHostRulesArray.parse(@fetched['hostRules'], to_s)
@name = @fetched['name']
@path_matchers = GoogleInSpec::Compute::Property::UrlMapPathMatchersArray.parse(@fetched['pathMatchers'], to_s)
@tests = GoogleInSpec::Compute::Property::UrlMapTestsArray.parse(@fetched['tests'], to_s)
Expand Down
8 changes: 4 additions & 4 deletions libraries/google_compute_url_maps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class ComputeUrlMaps < GcpResourceBase

filter_table_config = FilterTable.create

filter_table_config.add(:ids, field: :id)
filter_table_config.add(:creation_timestamps, field: :creation_timestamp)
filter_table_config.add(:default_services, field: :default_service)
filter_table_config.add(:descriptions, field: :description)
filter_table_config.add(:host_rules, field: :host_rules)
filter_table_config.add(:ids, field: :id)
filter_table_config.add(:fingerprints, field: :fingerprint)
filter_table_config.add(:host_rules, field: :host_rules)
filter_table_config.add(:names, field: :name)
filter_table_config.add(:path_matchers, field: :path_matchers)
filter_table_config.add(:tests, field: :tests)
Expand Down Expand Up @@ -71,12 +71,12 @@ def transform(key, value)

def transformers
{
'id' => ->(obj) { return :id, obj['id'] },
'creationTimestamp' => ->(obj) { return :creation_timestamp, parse_time_string(obj['creationTimestamp']) },
'defaultService' => ->(obj) { return :default_service, obj['defaultService'] },
'description' => ->(obj) { return :description, obj['description'] },
'hostRules' => ->(obj) { return :host_rules, GoogleInSpec::Compute::Property::UrlMapHostRulesArray.parse(obj['hostRules'], to_s) },
'id' => ->(obj) { return :id, obj['id'] },
'fingerprint' => ->(obj) { return :fingerprint, obj['fingerprint'] },
'hostRules' => ->(obj) { return :host_rules, GoogleInSpec::Compute::Property::UrlMapHostRulesArray.parse(obj['hostRules'], to_s) },
'name' => ->(obj) { return :name, obj['name'] },
'pathMatchers' => ->(obj) { return :path_matchers, GoogleInSpec::Compute::Property::UrlMapPathMatchersArray.parse(obj['pathMatchers'], to_s) },
'tests' => ->(obj) { return :tests, GoogleInSpec::Compute::Property::UrlMapTestsArray.parse(obj['tests'], to_s) },
Expand Down

0 comments on commit 5d133c3

Please sign in to comment.