From e0445ecd8e28e7e9d697b8e4ea5419fa7f4a83aa Mon Sep 17 00:00:00 2001 From: diogoEstevesCiT <80709292+diogoEsteves42@users.noreply.github.com> Date: Wed, 5 Apr 2023 19:32:49 +0000 Subject: [PATCH] urlLists into network services (#7592) --- mmv1/products/networksecurity/UrlLists.yaml | 103 ++++++++++++++++++ ...network_security_url_lists_advanced.tf.erb | 7 ++ .../network_security_url_lists_basic.tf.erb | 6 + ...rce_network_security_url_lists_test.go.erb | 63 +++++++++++ 4 files changed, 179 insertions(+) create mode 100644 mmv1/products/networksecurity/UrlLists.yaml create mode 100644 mmv1/templates/terraform/examples/network_security_url_lists_advanced.tf.erb create mode 100644 mmv1/templates/terraform/examples/network_security_url_lists_basic.tf.erb create mode 100644 mmv1/third_party/terraform/tests/resource_network_security_url_lists_test.go.erb diff --git a/mmv1/products/networksecurity/UrlLists.yaml b/mmv1/products/networksecurity/UrlLists.yaml new file mode 100644 index 000000000000..8b0d9a9f7d5f --- /dev/null +++ b/mmv1/products/networksecurity/UrlLists.yaml @@ -0,0 +1,103 @@ +# Copyright 2023 Google Inc. +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +!ruby/object:Api::Resource +name: "UrlLists" +base_url: "projects/{{project}}/locations/{{location}}/urlLists" +create_url: "projects/{{project}}/locations/{{location}}/urlLists?urlListId={{name}}" +self_link: "projects/{{project}}/locations/{{location}}/urlLists/{{name}}" +min_version: beta +update_verb: :PATCH +update_mask: true +description: | + UrlList proto helps users to set reusable, independently manageable lists of hosts, host patterns, URLs, URL patterns. +references: + !ruby/object:Api::Resource::ReferenceLinks # TODO(diogoesteves): change the url to beta once it is available. + guides: + "Use UrlLists": " https://cloud.google.com/secure-web-proxy/docs/use-url-list" + api: "https://cloud.google.com/secure-web-proxy/docs/reference/network-security/rest/v1alpha1/projects.locations.urlLists" +async: !ruby/object:Api::OpAsync + operation: !ruby/object:Api::OpAsync::Operation + path: "name" + base_url: "{{op_id}}" + wait_ms: 1000 + timeouts: !ruby/object:Api::Timeouts + insert_minutes: 30 + update_minutes: 30 + delete_minutes: 30 + result: !ruby/object:Api::OpAsync::Result + path: "response" + status: !ruby/object:Api::OpAsync::Status + path: "done" + complete: true + allowed: + - true + - false + error: !ruby/object:Api::OpAsync::Error + path: "error" + message: "message" +autogen_async: true +import_format: ["projects/{{project}}/locations/{{location}}/urlLists/{{name}}"] +examples: + - !ruby/object:Provider::Terraform::Examples + min_version: beta + name: "network_security_url_lists_basic" + primary_resource_id: "default" + vars: + resource_name: "my-url-lists" + - !ruby/object:Provider::Terraform::Examples + min_version: beta + name: "network_security_url_lists_advanced" + primary_resource_id: "default" + vars: + resource_name: "my-url-lists" +parameters: + - !ruby/object:Api::Type::String + name: "name" + required: true + url_param_only: true + description: | + Short name of the UrlList resource to be created. + This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. 'urlList'. + - !ruby/object:Api::Type::String + name: "location" + required: true + description: | + The location of the url lists. + url_param_only: true +properties: + - !ruby/object:Api::Type::Time + name: "createTime" + description: | + Output only. Time when the security policy was created. + A timestamp in RFC3339 UTC 'Zulu' format, with nanosecond resolution and up to nine fractional digits. + Examples: '2014-10-02T15:01:23Z' and '2014-10-02T15:01:23.045123456Z' + output: true + - !ruby/object:Api::Type::Time + name: "updateTime" + description: | + Output only. Time when the security policy was updated. + A timestamp in RFC3339 UTC 'Zulu' format, with nanosecond resolution and up to nine fractional digits. + Examples: '2014-10-02T15:01:23Z' and '2014-10-02T15:01:23.045123456Z'. + output: true + - !ruby/object:Api::Type::String + name: "description" + description: | + Free-text description of the resource. + - !ruby/object:Api::Type::Array + name: "values" + item_type: Api::Type::String + required: true + description: | + FQDNs and URLs. diff --git a/mmv1/templates/terraform/examples/network_security_url_lists_advanced.tf.erb b/mmv1/templates/terraform/examples/network_security_url_lists_advanced.tf.erb new file mode 100644 index 000000000000..dbd19f9aa9f4 --- /dev/null +++ b/mmv1/templates/terraform/examples/network_security_url_lists_advanced.tf.erb @@ -0,0 +1,7 @@ +resource "google_network_security_url_lists" "<%= ctx[:primary_resource_id] %>" { + provider = google-beta + name = "<%= ctx[:vars]['resource_name'] %>" + location = "us-central1" + description = "my description" + values = ["www.example.com", "about.example.com", "github.com/example-org/*"] +} \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/network_security_url_lists_basic.tf.erb b/mmv1/templates/terraform/examples/network_security_url_lists_basic.tf.erb new file mode 100644 index 000000000000..97eba9702ced --- /dev/null +++ b/mmv1/templates/terraform/examples/network_security_url_lists_basic.tf.erb @@ -0,0 +1,6 @@ +resource "google_network_security_url_lists" "<%= ctx[:primary_resource_id] %>" { + provider = google-beta + name = "<%= ctx[:vars]['resource_name'] %>" + location = "us-central1" + values = ["www.example.com"] +} \ No newline at end of file diff --git a/mmv1/third_party/terraform/tests/resource_network_security_url_lists_test.go.erb b/mmv1/third_party/terraform/tests/resource_network_security_url_lists_test.go.erb new file mode 100644 index 000000000000..6c2d36c050f7 --- /dev/null +++ b/mmv1/third_party/terraform/tests/resource_network_security_url_lists_test.go.erb @@ -0,0 +1,63 @@ +<% autogen_exception -%> +package google +<% unless version == 'ga' -%> + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccNetworkSecurityUrlLists_update(t *testing.T){ + t.Parallel() + + urlListsName := fmt.Sprintf("tf-test-url-lists-%s", RandString(t, 10)) + + VcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckNetworkSecurityUrlListsDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccNetworkSecurityUrlLists_basic(urlListsName), + }, + { + ResourceName: "google_network_security_url_lists.foobar", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccNetworkSecurityUrlLists_update(urlListsName), + }, + { + ResourceName: "google_network_security_url_lists.foobar", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccNetworkSecurityUrlLists_basic(urlListsName string) string { + return fmt.Sprintf(` +resource "google_network_security_url_lists" "foobar" { + name = "%s" + location = "us-central1" + values = ["www.example.com"] +} +`, urlListsName) +} + +func testAccNetworkSecurityUrlLists_update(urlListsName string) string { + return fmt.Sprintf(` +resource "google_network_security_url_lists" "foobar" { + name = "%s" + location = "us-central1" + description = "my description" + values = ["www.example.com", "about.example.com", "github.com/example-org/*"] +} +`, urlListsName) +} + +<% end -%> \ No newline at end of file