From 05d558d33ff2bcf8a57d3df11df0e7cbfaac0e29 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 28 Jan 2019 13:50:41 -0800 Subject: [PATCH] Add disable_dependent_services to google_project_service resource. (#2938) /cc @rileykarson --- google/config.go | 4 +- google/resource_google_project_service.go | 8 +- .../resource_google_project_service_test.go | 77 +++ google/resource_google_project_services.go | 25 +- google/serviceusage_operation.go | 4 +- .../{v1beta1 => v1}/serviceusage-api.json | 188 +++--- .../{v1beta1 => v1}/serviceusage-gen.go | 575 ++++++++++++------ vendor/modules.txt | 2 +- .../r/google_project_service.html.markdown | 5 + 9 files changed, 593 insertions(+), 295 deletions(-) rename vendor/google.golang.org/api/serviceusage/{v1beta1 => v1}/serviceusage-api.json (96%) rename vendor/google.golang.org/api/serviceusage/{v1beta1 => v1}/serviceusage-gen.go (93%) diff --git a/google/config.go b/google/config.go index 4d098098..f872cbc1 100644 --- a/google/config.go +++ b/google/config.go @@ -38,7 +38,7 @@ import ( redis "google.golang.org/api/redis/v1beta1" runtimeconfig "google.golang.org/api/runtimeconfig/v1beta1" "google.golang.org/api/servicemanagement/v1" - serviceusage "google.golang.org/api/serviceusage/v1beta1" + "google.golang.org/api/serviceusage/v1" "google.golang.org/api/sourcerepo/v1" "google.golang.org/api/spanner/v1" sqladmin "google.golang.org/api/sqladmin/v1beta4" @@ -86,7 +86,7 @@ type Config struct { clientSqlAdmin *sqladmin.Service clientIAM *iam.Service clientServiceMan *servicemanagement.APIService - clientServiceUsage *serviceusage.APIService + clientServiceUsage *serviceusage.Service clientBigQuery *bigquery.Service clientCloudFunctions *cloudfunctions.Service clientCloudIoT *cloudiot.Service diff --git a/google/resource_google_project_service.go b/google/resource_google_project_service.go index f8408c92..e8599334 100644 --- a/google/resource_google_project_service.go +++ b/google/resource_google_project_service.go @@ -32,6 +32,12 @@ func resourceGoogleProjectService() *schema.Resource { Computed: true, ForceNew: true, }, + + "disable_dependent_services": { + Type: schema.TypeBool, + Optional: true, + }, + "disable_on_destroy": { Type: schema.TypeBool, Optional: true, @@ -120,7 +126,7 @@ func resourceGoogleProjectServiceDelete(d *schema.ResourceData, meta interface{} return nil } - if err = disableService(id.service, id.project, config); err != nil { + if err = disableService(id.service, id.project, config, d.Get("disable_dependent_services").(bool)); err != nil { return fmt.Errorf("Error disabling service: %s", err) } diff --git a/google/resource_google_project_service_test.go b/google/resource_google_project_service_test.go index 3510fdac..089c0bc7 100644 --- a/google/resource_google_project_service_test.go +++ b/google/resource_google_project_service_test.go @@ -2,6 +2,7 @@ package google import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform/helper/acctest" @@ -63,6 +64,46 @@ func TestAccProjectService_basic(t *testing.T) { }) } +func TestAccProjectService_disableDependentServices(t *testing.T) { + t.Parallel() + + org := getTestOrgFromEnv(t) + pid := "terraform-" + acctest.RandString(10) + services := []string{"cloudbuild.googleapis.com", "containerregistry.googleapis.com"} + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccProjectService_disableDependentServices(services, pid, pname, org, "false"), + }, + { + ResourceName: "google_project_service.test", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"disable_on_destroy"}, + }, + { + Config: testAccProjectService_dependencyRemoved(services, pid, pname, org), + ExpectError: regexp.MustCompile("Please specify disable_dependent_services=true if you want to proceed with disabling all services."), + }, + { + Config: testAccProjectService_disableDependentServices(services, pid, pname, org, "true"), + }, + { + ResourceName: "google_project_service.test", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"disable_on_destroy"}, + }, + { + Config: testAccProjectService_dependencyRemoved(services, pid, pname, org), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + func TestAccProjectService_handleNotFound(t *testing.T) { t.Parallel() @@ -136,6 +177,42 @@ resource "google_project_service" "test2" { `, pid, name, org, services[0], services[1]) } +func testAccProjectService_disableDependentServices(services []string, pid, name, org, disableDependentServices string) string { + return fmt.Sprintf(` +resource "google_project" "acceptance" { + project_id = "%s" + name = "%s" + org_id = "%s" +} + +resource "google_project_service" "test" { + project = "${google_project.acceptance.project_id}" + service = "%s" +} + +resource "google_project_service" "test2" { + project = "${google_project.acceptance.project_id}" + service = "%s" + disable_dependent_services = %s +} +`, pid, name, org, services[0], services[1], disableDependentServices) +} + +func testAccProjectService_dependencyRemoved(services []string, pid, name, org string) string { + return fmt.Sprintf(` +resource "google_project" "acceptance" { + project_id = "%s" + name = "%s" + org_id = "%s" +} + +resource "google_project_service" "test" { + project = "${google_project.acceptance.project_id}" + service = "%s" +} +`, pid, name, org, services[0]) +} + func testAccProjectService_noDisable(services []string, pid, name, org string) string { return fmt.Sprintf(` resource "google_project" "acceptance" { diff --git a/google/resource_google_project_services.go b/google/resource_google_project_services.go index 9029360a..feaa24e4 100644 --- a/google/resource_google_project_services.go +++ b/google/resource_google_project_services.go @@ -4,12 +4,13 @@ import ( "context" "fmt" "log" + "sort" "strings" "github.com/hashicorp/errwrap" "github.com/hashicorp/terraform/helper/schema" "google.golang.org/api/googleapi" - "google.golang.org/api/serviceusage/v1beta1" + "google.golang.org/api/serviceusage/v1" ) func resourceGoogleProjectServices() *schema.Resource { @@ -129,7 +130,7 @@ func resourceGoogleProjectServicesDelete(d *schema.ResourceData, meta interface{ config := meta.(*Config) services := resourceServices(d) for _, s := range services { - disableService(s, d.Id(), config) + disableService(s, d.Id(), config, true) } d.SetId("") return nil @@ -148,19 +149,21 @@ func reconcileServices(cfgServices, apiServices []string, config *Config, pid st return sm } + sort.Strings(cfgServices) cfgMap := m(cfgServices) + log.Printf("[DEBUG]: Saw the following services in config: %v", cfgServices) apiMap := m(apiServices) + log.Printf("[DEBUG]: Saw the following services enabled: %v", apiServices) for k := range apiMap { if _, ok := cfgMap[k]; !ok { - // The service in the API is not in the config; disable it. - err := disableService(k, pid, config) + log.Printf("[DEBUG]: Disabling %s as it's enabled upstream but not in config", k) + err := disableService(k, pid, config, true) if err != nil { return err } } else { - // The service exists in the config and the API, so we don't need - // to re-enable it + log.Printf("[DEBUG]: Skipping %s as it's enabled in both config and upstream", k) delete(cfgMap, k) } } @@ -169,6 +172,8 @@ func reconcileServices(cfgServices, apiServices []string, config *Config, pid st for k := range cfgMap { keys = append(keys, k) } + sort.Strings(keys) + log.Printf("[DEBUG]: Enabling the following services: %v", keys) err := enableServices(keys, pid, config) if err != nil { return err @@ -233,7 +238,7 @@ func enableServices(s []string, pid string, config *Config) error { // It's not permitted to enable more than 20 services in one API call (even // for batch). // - // https://godoc.org/google.golang.org/api/serviceusage/v1beta1#BatchEnableServicesRequest + // https://godoc.org/google.golang.org/api/serviceusage/v1#BatchEnableServicesRequest batchSize := 20 for i := 0; i < len(s); i += batchSize { @@ -334,10 +339,12 @@ func diffStringSlice(wanted, actual []string) []string { return missing } -func disableService(s, pid string, config *Config) error { +func disableService(s, pid string, config *Config, disableDependentServices bool) error { err := retryTime(func() error { name := fmt.Sprintf("projects/%s/services/%s", pid, s) - sop, err := config.clientServiceUsage.Services.Disable(name, &serviceusage.DisableServiceRequest{}).Do() + sop, err := config.clientServiceUsage.Services.Disable(name, &serviceusage.DisableServiceRequest{ + DisableDependentServices: disableDependentServices, + }).Do() if err != nil { return err } diff --git a/google/serviceusage_operation.go b/google/serviceusage_operation.go index e595fd4c..88eb9a47 100644 --- a/google/serviceusage_operation.go +++ b/google/serviceusage_operation.go @@ -3,11 +3,11 @@ package google import ( "fmt" - serviceusage "google.golang.org/api/serviceusage/v1beta1" + "google.golang.org/api/serviceusage/v1" ) type ServiceUsageOperationWaiter struct { - Service *serviceusage.APIService + Service *serviceusage.Service CommonOperationWaiter } diff --git a/vendor/google.golang.org/api/serviceusage/v1beta1/serviceusage-api.json b/vendor/google.golang.org/api/serviceusage/v1/serviceusage-api.json similarity index 96% rename from vendor/google.golang.org/api/serviceusage/v1beta1/serviceusage-api.json rename to vendor/google.golang.org/api/serviceusage/v1/serviceusage-api.json index d974227a..a5a3704c 100644 --- a/vendor/google.golang.org/api/serviceusage/v1beta1/serviceusage-api.json +++ b/vendor/google.golang.org/api/serviceusage/v1/serviceusage-api.json @@ -26,7 +26,7 @@ "x16": "http://www.google.com/images/icons/product/search-16.gif", "x32": "http://www.google.com/images/icons/product/search-32.gif" }, - "id": "serviceusage:v1beta1", + "id": "serviceusage:v1", "kind": "discovery#restDescription", "name": "serviceusage", "ownerDomain": "google.com", @@ -112,9 +112,64 @@ "resources": { "operations": { "methods": { + "cancel": { + "description": "Starts asynchronous cancellation on a long-running operation. The server\nmakes a best effort to cancel the operation, but success is not\nguaranteed. If the server doesn't support this method, it returns\n`google.rpc.Code.UNIMPLEMENTED`. Clients can use\nOperations.GetOperation or\nother methods to check whether the cancellation succeeded or whether the\noperation completed despite cancellation. On successful cancellation,\nthe operation is not deleted; instead, it becomes an operation with\nan Operation.error value with a google.rpc.Status.code of 1,\ncorresponding to `Code.CANCELLED`.", + "flatPath": "v1/operations/{operationsId}:cancel", + "httpMethod": "POST", + "id": "serviceusage.operations.cancel", + "parameterOrder": [ + "name" + ], + "parameters": { + "name": { + "description": "The name of the operation resource to be cancelled.", + "location": "path", + "pattern": "^operations/.+$", + "required": true, + "type": "string" + } + }, + "path": "v1/{+name}:cancel", + "request": { + "$ref": "CancelOperationRequest" + }, + "response": { + "$ref": "Empty" + }, + "scopes": [ + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/service.management" + ] + }, + "delete": { + "description": "Deletes a long-running operation. This method indicates that the client is\nno longer interested in the operation result. It does not cancel the\noperation. If the server doesn't support this method, it returns\n`google.rpc.Code.UNIMPLEMENTED`.", + "flatPath": "v1/operations/{operationsId}", + "httpMethod": "DELETE", + "id": "serviceusage.operations.delete", + "parameterOrder": [ + "name" + ], + "parameters": { + "name": { + "description": "The name of the operation resource to be deleted.", + "location": "path", + "pattern": "^operations/.+$", + "required": true, + "type": "string" + } + }, + "path": "v1/{+name}", + "response": { + "$ref": "Empty" + }, + "scopes": [ + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/service.management" + ] + }, "get": { "description": "Gets the latest state of a long-running operation. Clients can use this\nmethod to poll the operation result at intervals as recommended by the API\nservice.", - "flatPath": "v1beta1/operations/{operationsId}", + "flatPath": "v1/operations/{operationsId}", "httpMethod": "GET", "id": "serviceusage.operations.get", "parameterOrder": [ @@ -129,7 +184,7 @@ "type": "string" } }, - "path": "v1beta1/{+name}", + "path": "v1/{+name}", "response": { "$ref": "Operation" }, @@ -140,7 +195,7 @@ }, "list": { "description": "Lists operations that match the specified filter in the request. If the\nserver doesn't support this method, it returns `UNIMPLEMENTED`.\n\nNOTE: the `name` binding allows API services to override the binding\nto use different resource name schemes, such as `users/*/operations`. To\noverride the binding, API services can add a binding such as\n`\"/v1/{name=users/*}/operations\"` to their service configuration.\nFor backwards compatibility, the default name includes the operations\ncollection id, however overriding users must ensure the name binding\nis the parent resource, without the operations collection id.", - "flatPath": "v1beta1/operations", + "flatPath": "v1/operations", "httpMethod": "GET", "id": "serviceusage.operations.list", "parameterOrder": [], @@ -167,7 +222,7 @@ "type": "string" } }, - "path": "v1beta1/operations", + "path": "v1/operations", "response": { "$ref": "ListOperationsResponse" }, @@ -181,8 +236,8 @@ "services": { "methods": { "batchEnable": { - "description": "Enable multiple services on a project. The operation is atomic: if enabling\nany service fails, then the entire batch fails, and no state changes occur.\n\nOperation\u003cresponse: google.protobuf.Empty\u003e", - "flatPath": "v1beta1/{v1beta1Id}/{v1beta1Id1}/services:batchEnable", + "description": "Enable multiple services on a project. The operation is atomic: if enabling\nany service fails, then the entire batch fails, and no state changes occur.\n\nOperation\u003cresponse: BatchEnableServicesResponse\u003e", + "flatPath": "v1/{v1Id}/{v1Id1}/services:batchEnable", "httpMethod": "POST", "id": "serviceusage.services.batchEnable", "parameterOrder": [ @@ -197,7 +252,7 @@ "type": "string" } }, - "path": "v1beta1/{+parent}/services:batchEnable", + "path": "v1/{+parent}/services:batchEnable", "request": { "$ref": "BatchEnableServicesRequest" }, @@ -210,8 +265,8 @@ ] }, "disable": { - "description": "Disable a service so that it can no longer be used with a project.\nThis prevents unintended usage that may cause unexpected billing\ncharges or security leaks.\n\nIt is not valid to call the disable method on a service that is not\ncurrently enabled. Callers will receive a `FAILED_PRECONDITION` status if\nthe target service is not currently enabled.\n\nOperation\u003cresponse: google.protobuf.Empty\u003e", - "flatPath": "v1beta1/{v1beta1Id}/{v1beta1Id1}/services/{servicesId}:disable", + "description": "Disable a service so that it can no longer be used with a project.\nThis prevents unintended usage that may cause unexpected billing\ncharges or security leaks.\n\nIt is not valid to call the disable method on a service that is not\ncurrently enabled. Callers will receive a `FAILED_PRECONDITION` status if\nthe target service is not currently enabled.\n\nOperation\u003cresponse: DisableServiceResponse\u003e", + "flatPath": "v1/{v1Id}/{v1Id1}/services/{servicesId}:disable", "httpMethod": "POST", "id": "serviceusage.services.disable", "parameterOrder": [ @@ -226,7 +281,7 @@ "type": "string" } }, - "path": "v1beta1/{+name}:disable", + "path": "v1/{+name}:disable", "request": { "$ref": "DisableServiceRequest" }, @@ -239,8 +294,8 @@ ] }, "enable": { - "description": "Enable a service so that it can be used with a project.\n\nOperation\u003cresponse: google.protobuf.Empty\u003e", - "flatPath": "v1beta1/{v1beta1Id}/{v1beta1Id1}/services/{servicesId}:enable", + "description": "Enable a service so that it can be used with a project.\n\nOperation\u003cresponse: EnableServiceResponse\u003e", + "flatPath": "v1/{v1Id}/{v1Id1}/services/{servicesId}:enable", "httpMethod": "POST", "id": "serviceusage.services.enable", "parameterOrder": [ @@ -255,7 +310,7 @@ "type": "string" } }, - "path": "v1beta1/{+name}:enable", + "path": "v1/{+name}:enable", "request": { "$ref": "EnableServiceRequest" }, @@ -269,7 +324,7 @@ }, "get": { "description": "Returns the service configuration and enabled state for a given service.", - "flatPath": "v1beta1/{v1beta1Id}/{v1beta1Id1}/services/{servicesId}", + "flatPath": "v1/{v1Id}/{v1Id1}/services/{servicesId}", "httpMethod": "GET", "id": "serviceusage.services.get", "parameterOrder": [ @@ -284,9 +339,9 @@ "type": "string" } }, - "path": "v1beta1/{+name}", + "path": "v1/{+name}", "response": { - "$ref": "Service" + "$ref": "GoogleApiServiceusageV1Service" }, "scopes": [ "https://www.googleapis.com/auth/cloud-platform", @@ -295,7 +350,7 @@ }, "list": { "description": "List all services available to the specified project, and the current\nstate of those services with respect to the project. The list includes\nall public services, all services for which the calling user has the\n`servicemanagement.services.bind` permission, and all services that have\nalready been enabled on the project. The list can be filtered to\nonly include services in a specific state, for example to only include\nservices enabled on the project.", - "flatPath": "v1beta1/{v1beta1Id}/{v1beta1Id1}/services", + "flatPath": "v1/{v1Id}/{v1Id1}/services", "httpMethod": "GET", "id": "serviceusage.services.list", "parameterOrder": [ @@ -326,7 +381,7 @@ "type": "string" } }, - "path": "v1beta1/{+parent}/services", + "path": "v1/{+parent}/services", "response": { "$ref": "ListServicesResponse" }, @@ -604,6 +659,12 @@ }, "type": "object" }, + "CancelOperationRequest": { + "description": "The request message for Operations.CancelOperation.", + "id": "CancelOperationRequest", + "properties": {}, + "type": "object" + }, "Context": { "description": "`Context` defines which contexts an API requests.\n\nExample:\n\n context:\n rules:\n - selector: \"*\"\n requested:\n - google.rpc.context.ProjectContext\n - google.rpc.context.OriginContext\n\nThe above specifies that all methods in the API request\n`google.rpc.context.ProjectContext` and\n`google.rpc.context.OriginContext`.\n\nAvailable context types are defined in package\n`google.rpc.context`.\n\nThis also provides mechanism to whitelist any protobuf message extension that\ncan be sent in grpc metadata using “x-goog-ext-\u003cextension_id\u003e-bin” and\n“x-goog-ext-\u003cextension_id\u003e-jspb” format. For example, list any service\nspecific protobuf types that can appear in grpc metadata as follows in your\nyaml file:\n\nExample:\n\n context:\n rules:\n - selector: \"google.example.library.v1.LibraryService.CreateBook\"\n allowed_request_extensions:\n - google.foo.v1.NewExtension\n allowed_response_extensions:\n - google.foo.v1.NewExtension\n\nYou can also specify extension ID instead of fully qualified extension name\nhere.", "id": "Context", @@ -722,7 +783,12 @@ "DisableServiceRequest": { "description": "Request message for the `DisableService` method.", "id": "DisableServiceRequest", - "properties": {}, + "properties": { + "disableDependentServices": { + "description": "Indicates if services that are enabled and which depend on this service\nshould also be disabled. If not set, an error will be generated if any\nenabled services depend on the service to be disabled. When set, the\nservice, and any enabled services that depend on it, will be disabled\ntogether.", + "type": "boolean" + } + }, "type": "object" }, "DisableServiceResponse": { @@ -1402,7 +1468,7 @@ "services": { "description": "The available services for the requested project.", "items": { - "$ref": "Service" + "$ref": "GoogleApiServiceusageV1Service" }, "type": "array" } @@ -1912,84 +1978,6 @@ }, "type": "object" }, - "Service": { - "description": "A service that is available for use by the consumer.", - "id": "Service", - "properties": { - "config": { - "$ref": "ServiceConfig", - "description": "The service configuration of the available service.\nSome fields may be filtered out of the configuration in responses to\nthe `ListServices` method. These fields are present only in responses to\nthe `GetService` method." - }, - "name": { - "description": "The resource name of the consumer and service.\n\nA valid name would be:\n- projects/123/services/serviceusage.googleapis.com", - "type": "string" - }, - "parent": { - "description": "The resource name of the consumer.\n\nA valid name would be:\n- projects/123", - "type": "string" - }, - "state": { - "description": "Whether or not the service has been enabled for use by the consumer.", - "enum": [ - "STATE_UNSPECIFIED", - "DISABLED", - "ENABLED" - ], - "enumDescriptions": [ - "The default value, which indicates that the enabled state of the service\nis unspecified or not meaningful. Currently, all consumers other than\nprojects (such as folders and organizations) are always in this state.", - "The service cannot be used by this consumer. It has either been explicitly\ndisabled, or has never been enabled.", - "The service has been explicitly enabled for use by this consumer." - ], - "type": "string" - } - }, - "type": "object" - }, - "ServiceConfig": { - "description": "The configuration of the service.", - "id": "ServiceConfig", - "properties": { - "apis": { - "description": "A list of API interfaces exported by this service. Contains only the names,\nversions, and method names of the interfaces.", - "items": { - "$ref": "Api" - }, - "type": "array" - }, - "authentication": { - "$ref": "Authentication", - "description": "Auth configuration. Contains only the OAuth rules." - }, - "documentation": { - "$ref": "Documentation", - "description": "Additional API documentation. Contains only the summary and the\ndocumentation URL." - }, - "endpoints": { - "description": "Configuration for network endpoints. Contains only the names and aliases\nof the endpoints.", - "items": { - "$ref": "Endpoint" - }, - "type": "array" - }, - "name": { - "description": "The DNS address at which this service is available.\n\nAn example DNS address would be:\n`calendar.googleapis.com`.", - "type": "string" - }, - "quota": { - "$ref": "Quota", - "description": "Quota configuration." - }, - "title": { - "description": "The product title for this service.", - "type": "string" - }, - "usage": { - "$ref": "Usage", - "description": "Configuration controlling usage of this service." - } - }, - "type": "object" - }, "SourceContext": { "description": "`SourceContext` represents information about the source of a\nprotobuf element, like the file in which it is defined.", "id": "SourceContext", @@ -2192,6 +2180,6 @@ }, "servicePath": "", "title": "Service Usage API", - "version": "v1beta1", + "version": "v1", "version_module": true } \ No newline at end of file diff --git a/vendor/google.golang.org/api/serviceusage/v1beta1/serviceusage-gen.go b/vendor/google.golang.org/api/serviceusage/v1/serviceusage-gen.go similarity index 93% rename from vendor/google.golang.org/api/serviceusage/v1beta1/serviceusage-gen.go rename to vendor/google.golang.org/api/serviceusage/v1/serviceusage-gen.go index 99e2ac05..418bc408 100644 --- a/vendor/google.golang.org/api/serviceusage/v1beta1/serviceusage-gen.go +++ b/vendor/google.golang.org/api/serviceusage/v1/serviceusage-gen.go @@ -10,10 +10,10 @@ // // Usage example: // -// import "google.golang.org/api/serviceusage/v1beta1" +// import "google.golang.org/api/serviceusage/v1" // ... // serviceusageService, err := serviceusage.New(oauthHttpClient) -package serviceusage // import "google.golang.org/api/serviceusage/v1beta1" +package serviceusage // import "google.golang.org/api/serviceusage/v1" import ( "bytes" @@ -45,9 +45,9 @@ var _ = errors.New var _ = strings.Replace var _ = context.Canceled -const apiId = "serviceusage:v1beta1" +const apiId = "serviceusage:v1" const apiName = "serviceusage" -const apiVersion = "v1beta1" +const apiVersion = "v1" const basePath = "https://serviceusage.googleapis.com/" // OAuth2 scopes used by this API. @@ -62,17 +62,17 @@ const ( ServiceManagementScope = "https://www.googleapis.com/auth/service.management" ) -func New(client *http.Client) (*APIService, error) { +func New(client *http.Client) (*Service, error) { if client == nil { return nil, errors.New("client is nil") } - s := &APIService{client: client, BasePath: basePath} + s := &Service{client: client, BasePath: basePath} s.Operations = NewOperationsService(s) s.Services = NewServicesService(s) return s, nil } -type APIService struct { +type Service struct { client *http.Client BasePath string // API endpoint base URL UserAgent string // optional additional User-Agent fragment @@ -82,29 +82,29 @@ type APIService struct { Services *ServicesService } -func (s *APIService) userAgent() string { +func (s *Service) userAgent() string { if s.UserAgent == "" { return googleapi.UserAgent } return googleapi.UserAgent + " " + s.UserAgent } -func NewOperationsService(s *APIService) *OperationsService { +func NewOperationsService(s *Service) *OperationsService { rs := &OperationsService{s: s} return rs } type OperationsService struct { - s *APIService + s *Service } -func NewServicesService(s *APIService) *ServicesService { +func NewServicesService(s *Service) *ServicesService { rs := &ServicesService{s: s} return rs } type ServicesService struct { - s *APIService + s *Service } // Api: Api is a light-weight descriptor for an API @@ -780,6 +780,11 @@ func (s *BillingDestination) MarshalJSON() ([]byte, error) { return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } +// CancelOperationRequest: The request message for +// Operations.CancelOperation. +type CancelOperationRequest struct { +} + // Context: `Context` defines which contexts an API // requests. // @@ -1060,6 +1065,40 @@ func (s *CustomHttpPattern) MarshalJSON() ([]byte, error) { // DisableServiceRequest: Request message for the `DisableService` // method. type DisableServiceRequest struct { + // DisableDependentServices: Indicates if services that are enabled and + // which depend on this service + // should also be disabled. If not set, an error will be generated if + // any + // enabled services depend on the service to be disabled. When set, + // the + // service, and any enabled services that depend on it, will be + // disabled + // together. + DisableDependentServices bool `json:"disableDependentServices,omitempty"` + + // ForceSendFields is a list of field names (e.g. + // "DisableDependentServices") to unconditionally include in API + // requests. By default, fields with empty values are omitted from API + // requests. However, any non-pointer, non-interface field appearing in + // ForceSendFields will be sent to the server regardless of whether the + // field is empty or not. This may be used to include empty fields in + // Patch requests. + ForceSendFields []string `json:"-"` + + // NullFields is a list of field names (e.g. "DisableDependentServices") + // to include in API requests with the JSON null value. By default, + // fields with empty values are omitted from API requests. However, any + // field with an empty value appearing in NullFields will be sent to the + // server as null. It is an error if a field in this list has a + // non-empty value. This may be used to include null fields in Patch + // requests. + NullFields []string `json:"-"` +} + +func (s *DisableServiceRequest) MarshalJSON() ([]byte, error) { + type NoMethod DisableServiceRequest + raw := NoMethod(*s) + return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // DisableServiceResponse: Response message for the `DisableService` @@ -1282,6 +1321,9 @@ func (s *DocumentationRule) MarshalJSON() ([]byte, error) { // // The JSON representation for `Empty` is empty JSON object `{}`. type Empty struct { + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` } // EnableFailure: Provides error messages for the failing services. @@ -1891,6 +1933,10 @@ type GoogleApiServiceusageV1Service struct { // consumer. State string `json:"state,omitempty"` + // ServerResponse contains the HTTP response code and headers from the + // server. + googleapi.ServerResponse `json:"-"` + // ForceSendFields is a list of field names (e.g. "Config") to // unconditionally include in API requests. By default, fields with // empty values are omitted from API requests. However, any non-pointer, @@ -2544,7 +2590,7 @@ type ListServicesResponse struct { NextPageToken string `json:"nextPageToken,omitempty"` // Services: The available services for the requested project. - Services []*Service `json:"services,omitempty"` + Services []*GoogleApiServiceusageV1Service `json:"services,omitempty"` // ServerResponse contains the HTTP response code and headers from the // server. @@ -3928,130 +3974,6 @@ func (s *QuotaLimit) MarshalJSON() ([]byte, error) { return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } -// Service: A service that is available for use by the consumer. -type Service struct { - // Config: The service configuration of the available service. - // Some fields may be filtered out of the configuration in responses - // to - // the `ListServices` method. These fields are present only in responses - // to - // the `GetService` method. - Config *ServiceConfig `json:"config,omitempty"` - - // Name: The resource name of the consumer and service. - // - // A valid name would be: - // - projects/123/services/serviceusage.googleapis.com - Name string `json:"name,omitempty"` - - // Parent: The resource name of the consumer. - // - // A valid name would be: - // - projects/123 - Parent string `json:"parent,omitempty"` - - // State: Whether or not the service has been enabled for use by the - // consumer. - // - // Possible values: - // "STATE_UNSPECIFIED" - The default value, which indicates that the - // enabled state of the service - // is unspecified or not meaningful. Currently, all consumers other - // than - // projects (such as folders and organizations) are always in this - // state. - // "DISABLED" - The service cannot be used by this consumer. It has - // either been explicitly - // disabled, or has never been enabled. - // "ENABLED" - The service has been explicitly enabled for use by this - // consumer. - State string `json:"state,omitempty"` - - // ServerResponse contains the HTTP response code and headers from the - // server. - googleapi.ServerResponse `json:"-"` - - // ForceSendFields is a list of field names (e.g. "Config") to - // unconditionally include in API requests. By default, fields with - // empty values are omitted from API requests. However, any non-pointer, - // non-interface field appearing in ForceSendFields will be sent to the - // server regardless of whether the field is empty or not. This may be - // used to include empty fields in Patch requests. - ForceSendFields []string `json:"-"` - - // NullFields is a list of field names (e.g. "Config") to include in API - // requests with the JSON null value. By default, fields with empty - // values are omitted from API requests. However, any field with an - // empty value appearing in NullFields will be sent to the server as - // null. It is an error if a field in this list has a non-empty value. - // This may be used to include null fields in Patch requests. - NullFields []string `json:"-"` -} - -func (s *Service) MarshalJSON() ([]byte, error) { - type NoMethod Service - raw := NoMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) -} - -// ServiceConfig: The configuration of the service. -type ServiceConfig struct { - // Apis: A list of API interfaces exported by this service. Contains - // only the names, - // versions, and method names of the interfaces. - Apis []*Api `json:"apis,omitempty"` - - // Authentication: Auth configuration. Contains only the OAuth rules. - Authentication *Authentication `json:"authentication,omitempty"` - - // Documentation: Additional API documentation. Contains only the - // summary and the - // documentation URL. - Documentation *Documentation `json:"documentation,omitempty"` - - // Endpoints: Configuration for network endpoints. Contains only the - // names and aliases - // of the endpoints. - Endpoints []*Endpoint `json:"endpoints,omitempty"` - - // Name: The DNS address at which this service is available. - // - // An example DNS address would be: - // `calendar.googleapis.com`. - Name string `json:"name,omitempty"` - - // Quota: Quota configuration. - Quota *Quota `json:"quota,omitempty"` - - // Title: The product title for this service. - Title string `json:"title,omitempty"` - - // Usage: Configuration controlling usage of this service. - Usage *Usage `json:"usage,omitempty"` - - // ForceSendFields is a list of field names (e.g. "Apis") to - // unconditionally include in API requests. By default, fields with - // empty values are omitted from API requests. However, any non-pointer, - // non-interface field appearing in ForceSendFields will be sent to the - // server regardless of whether the field is empty or not. This may be - // used to include empty fields in Patch requests. - ForceSendFields []string `json:"-"` - - // NullFields is a list of field names (e.g. "Apis") to include in API - // requests with the JSON null value. By default, fields with empty - // values are omitted from API requests. However, any field with an - // empty value appearing in NullFields will be sent to the server as - // null. It is an error if a field in this list has a non-empty value. - // This may be used to include null fields in Patch requests. - NullFields []string `json:"-"` -} - -func (s *ServiceConfig) MarshalJSON() ([]byte, error) { - type NoMethod ServiceConfig - raw := NoMethod(*s) - return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) -} - // SourceContext: `SourceContext` represents information about the // source of a // protobuf element, like the file in which it is defined. @@ -4568,10 +4490,303 @@ func (s *UsageRule) MarshalJSON() ([]byte, error) { return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } +// method id "serviceusage.operations.cancel": + +type OperationsCancelCall struct { + s *Service + name string + canceloperationrequest *CancelOperationRequest + urlParams_ gensupport.URLParams + ctx_ context.Context + header_ http.Header +} + +// Cancel: Starts asynchronous cancellation on a long-running operation. +// The server +// makes a best effort to cancel the operation, but success is +// not +// guaranteed. If the server doesn't support this method, it +// returns +// `google.rpc.Code.UNIMPLEMENTED`. Clients can +// use +// Operations.GetOperation or +// other methods to check whether the cancellation succeeded or whether +// the +// operation completed despite cancellation. On successful +// cancellation, +// the operation is not deleted; instead, it becomes an operation +// with +// an Operation.error value with a google.rpc.Status.code of +// 1, +// corresponding to `Code.CANCELLED`. +func (r *OperationsService) Cancel(name string, canceloperationrequest *CancelOperationRequest) *OperationsCancelCall { + c := &OperationsCancelCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.name = name + c.canceloperationrequest = canceloperationrequest + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse +// for more information. +func (c *OperationsCancelCall) Fields(s ...googleapi.Field) *OperationsCancelCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// Context sets the context to be used in this call's Do method. Any +// pending HTTP request will be aborted if the provided context is +// canceled. +func (c *OperationsCancelCall) Context(ctx context.Context) *OperationsCancelCall { + c.ctx_ = ctx + return c +} + +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *OperationsCancelCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *OperationsCancelCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + var body io.Reader = nil + body, err := googleapi.WithoutDataWrapper.JSONReader(c.canceloperationrequest) + if err != nil { + return nil, err + } + reqHeaders.Set("Content-Type", "application/json") + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:cancel") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("POST", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + googleapi.Expand(req.URL, map[string]string{ + "name": c.name, + }) + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "serviceusage.operations.cancel" call. +// Exactly one of *Empty or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Empty.ServerResponse.Header or (if a response was returned at all) +// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to +// check whether the returned error was because http.StatusNotModified +// was returned. +func (c *OperationsCancelCall) Do(opts ...googleapi.CallOption) (*Empty, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, &googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + } + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, err + } + ret := &Empty{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Starts asynchronous cancellation on a long-running operation. The server\nmakes a best effort to cancel the operation, but success is not\nguaranteed. If the server doesn't support this method, it returns\n`google.rpc.Code.UNIMPLEMENTED`. Clients can use\nOperations.GetOperation or\nother methods to check whether the cancellation succeeded or whether the\noperation completed despite cancellation. On successful cancellation,\nthe operation is not deleted; instead, it becomes an operation with\nan Operation.error value with a google.rpc.Status.code of 1,\ncorresponding to `Code.CANCELLED`.", + // "flatPath": "v1/operations/{operationsId}:cancel", + // "httpMethod": "POST", + // "id": "serviceusage.operations.cancel", + // "parameterOrder": [ + // "name" + // ], + // "parameters": { + // "name": { + // "description": "The name of the operation resource to be cancelled.", + // "location": "path", + // "pattern": "^operations/.+$", + // "required": true, + // "type": "string" + // } + // }, + // "path": "v1/{+name}:cancel", + // "request": { + // "$ref": "CancelOperationRequest" + // }, + // "response": { + // "$ref": "Empty" + // }, + // "scopes": [ + // "https://www.googleapis.com/auth/cloud-platform", + // "https://www.googleapis.com/auth/service.management" + // ] + // } + +} + +// method id "serviceusage.operations.delete": + +type OperationsDeleteCall struct { + s *Service + name string + urlParams_ gensupport.URLParams + ctx_ context.Context + header_ http.Header +} + +// Delete: Deletes a long-running operation. This method indicates that +// the client is +// no longer interested in the operation result. It does not cancel +// the +// operation. If the server doesn't support this method, it +// returns +// `google.rpc.Code.UNIMPLEMENTED`. +func (r *OperationsService) Delete(name string) *OperationsDeleteCall { + c := &OperationsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} + c.name = name + return c +} + +// Fields allows partial responses to be retrieved. See +// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse +// for more information. +func (c *OperationsDeleteCall) Fields(s ...googleapi.Field) *OperationsDeleteCall { + c.urlParams_.Set("fields", googleapi.CombineFields(s)) + return c +} + +// Context sets the context to be used in this call's Do method. Any +// pending HTTP request will be aborted if the provided context is +// canceled. +func (c *OperationsDeleteCall) Context(ctx context.Context) *OperationsDeleteCall { + c.ctx_ = ctx + return c +} + +// Header returns an http.Header that can be modified by the caller to +// add HTTP headers to the request. +func (c *OperationsDeleteCall) Header() http.Header { + if c.header_ == nil { + c.header_ = make(http.Header) + } + return c.header_ +} + +func (c *OperationsDeleteCall) doRequest(alt string) (*http.Response, error) { + reqHeaders := make(http.Header) + for k, v := range c.header_ { + reqHeaders[k] = v + } + reqHeaders.Set("User-Agent", c.s.userAgent()) + var body io.Reader = nil + c.urlParams_.Set("alt", alt) + c.urlParams_.Set("prettyPrint", "false") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") + urls += "?" + c.urlParams_.Encode() + req, err := http.NewRequest("DELETE", urls, body) + if err != nil { + return nil, err + } + req.Header = reqHeaders + googleapi.Expand(req.URL, map[string]string{ + "name": c.name, + }) + return gensupport.SendRequest(c.ctx_, c.s.client, req) +} + +// Do executes the "serviceusage.operations.delete" call. +// Exactly one of *Empty or error will be non-nil. Any non-2xx status +// code is an error. Response headers are in either +// *Empty.ServerResponse.Header or (if a response was returned at all) +// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to +// check whether the returned error was because http.StatusNotModified +// was returned. +func (c *OperationsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { + gensupport.SetOptions(c.urlParams_, opts...) + res, err := c.doRequest("json") + if res != nil && res.StatusCode == http.StatusNotModified { + if res.Body != nil { + res.Body.Close() + } + return nil, &googleapi.Error{ + Code: res.StatusCode, + Header: res.Header, + } + } + if err != nil { + return nil, err + } + defer googleapi.CloseBody(res) + if err := googleapi.CheckResponse(res); err != nil { + return nil, err + } + ret := &Empty{ + ServerResponse: googleapi.ServerResponse{ + Header: res.Header, + HTTPStatusCode: res.StatusCode, + }, + } + target := &ret + if err := gensupport.DecodeResponse(target, res); err != nil { + return nil, err + } + return ret, nil + // { + // "description": "Deletes a long-running operation. This method indicates that the client is\nno longer interested in the operation result. It does not cancel the\noperation. If the server doesn't support this method, it returns\n`google.rpc.Code.UNIMPLEMENTED`.", + // "flatPath": "v1/operations/{operationsId}", + // "httpMethod": "DELETE", + // "id": "serviceusage.operations.delete", + // "parameterOrder": [ + // "name" + // ], + // "parameters": { + // "name": { + // "description": "The name of the operation resource to be deleted.", + // "location": "path", + // "pattern": "^operations/.+$", + // "required": true, + // "type": "string" + // } + // }, + // "path": "v1/{+name}", + // "response": { + // "$ref": "Empty" + // }, + // "scopes": [ + // "https://www.googleapis.com/auth/cloud-platform", + // "https://www.googleapis.com/auth/service.management" + // ] + // } + +} + // method id "serviceusage.operations.get": type OperationsGetCall struct { - s *APIService + s *Service name string urlParams_ gensupport.URLParams ifNoneMatch_ string @@ -4637,7 +4852,7 @@ func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) { var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") - urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+name}") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { @@ -4689,7 +4904,7 @@ func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) return ret, nil // { // "description": "Gets the latest state of a long-running operation. Clients can use this\nmethod to poll the operation result at intervals as recommended by the API\nservice.", - // "flatPath": "v1beta1/operations/{operationsId}", + // "flatPath": "v1/operations/{operationsId}", // "httpMethod": "GET", // "id": "serviceusage.operations.get", // "parameterOrder": [ @@ -4704,7 +4919,7 @@ func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) // "type": "string" // } // }, - // "path": "v1beta1/{+name}", + // "path": "v1/{+name}", // "response": { // "$ref": "Operation" // }, @@ -4719,7 +4934,7 @@ func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) // method id "serviceusage.operations.list": type OperationsListCall struct { - s *APIService + s *Service urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context @@ -4823,7 +5038,7 @@ func (c *OperationsListCall) doRequest(alt string) (*http.Response, error) { var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") - urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/operations") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1/operations") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { @@ -4872,7 +5087,7 @@ func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsRe return ret, nil // { // "description": "Lists operations that match the specified filter in the request. If the\nserver doesn't support this method, it returns `UNIMPLEMENTED`.\n\nNOTE: the `name` binding allows API services to override the binding\nto use different resource name schemes, such as `users/*/operations`. To\noverride the binding, API services can add a binding such as\n`\"/v1/{name=users/*}/operations\"` to their service configuration.\nFor backwards compatibility, the default name includes the operations\ncollection id, however overriding users must ensure the name binding\nis the parent resource, without the operations collection id.", - // "flatPath": "v1beta1/operations", + // "flatPath": "v1/operations", // "httpMethod": "GET", // "id": "serviceusage.operations.list", // "parameterOrder": [], @@ -4899,7 +5114,7 @@ func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsRe // "type": "string" // } // }, - // "path": "v1beta1/operations", + // "path": "v1/operations", // "response": { // "$ref": "ListOperationsResponse" // }, @@ -4935,7 +5150,7 @@ func (c *OperationsListCall) Pages(ctx context.Context, f func(*ListOperationsRe // method id "serviceusage.services.batchEnable": type ServicesBatchEnableCall struct { - s *APIService + s *Service parent string batchenableservicesrequest *BatchEnableServicesRequest urlParams_ gensupport.URLParams @@ -4948,7 +5163,7 @@ type ServicesBatchEnableCall struct { // any service fails, then the entire batch fails, and no state changes // occur. // -// Operation +// Operation func (r *ServicesService) BatchEnable(parent string, batchenableservicesrequest *BatchEnableServicesRequest) *ServicesBatchEnableCall { c := &ServicesBatchEnableCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.parent = parent @@ -4995,7 +5210,7 @@ func (c *ServicesBatchEnableCall) doRequest(alt string) (*http.Response, error) reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") - urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+parent}/services:batchEnable") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/services:batchEnable") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("POST", urls, body) if err != nil { @@ -5046,8 +5261,8 @@ func (c *ServicesBatchEnableCall) Do(opts ...googleapi.CallOption) (*Operation, } return ret, nil // { - // "description": "Enable multiple services on a project. The operation is atomic: if enabling\nany service fails, then the entire batch fails, and no state changes occur.\n\nOperation\u003cresponse: google.protobuf.Empty\u003e", - // "flatPath": "v1beta1/{v1beta1Id}/{v1beta1Id1}/services:batchEnable", + // "description": "Enable multiple services on a project. The operation is atomic: if enabling\nany service fails, then the entire batch fails, and no state changes occur.\n\nOperation\u003cresponse: BatchEnableServicesResponse\u003e", + // "flatPath": "v1/{v1Id}/{v1Id1}/services:batchEnable", // "httpMethod": "POST", // "id": "serviceusage.services.batchEnable", // "parameterOrder": [ @@ -5062,7 +5277,7 @@ func (c *ServicesBatchEnableCall) Do(opts ...googleapi.CallOption) (*Operation, // "type": "string" // } // }, - // "path": "v1beta1/{+parent}/services:batchEnable", + // "path": "v1/{+parent}/services:batchEnable", // "request": { // "$ref": "BatchEnableServicesRequest" // }, @@ -5080,7 +5295,7 @@ func (c *ServicesBatchEnableCall) Do(opts ...googleapi.CallOption) (*Operation, // method id "serviceusage.services.disable": type ServicesDisableCall struct { - s *APIService + s *Service name string disableservicerequest *DisableServiceRequest urlParams_ gensupport.URLParams @@ -5100,7 +5315,7 @@ type ServicesDisableCall struct { // status if // the target service is not currently enabled. // -// Operation +// Operation func (r *ServicesService) Disable(name string, disableservicerequest *DisableServiceRequest) *ServicesDisableCall { c := &ServicesDisableCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name @@ -5147,7 +5362,7 @@ func (c *ServicesDisableCall) doRequest(alt string) (*http.Response, error) { reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") - urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+name}:disable") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:disable") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("POST", urls, body) if err != nil { @@ -5198,8 +5413,8 @@ func (c *ServicesDisableCall) Do(opts ...googleapi.CallOption) (*Operation, erro } return ret, nil // { - // "description": "Disable a service so that it can no longer be used with a project.\nThis prevents unintended usage that may cause unexpected billing\ncharges or security leaks.\n\nIt is not valid to call the disable method on a service that is not\ncurrently enabled. Callers will receive a `FAILED_PRECONDITION` status if\nthe target service is not currently enabled.\n\nOperation\u003cresponse: google.protobuf.Empty\u003e", - // "flatPath": "v1beta1/{v1beta1Id}/{v1beta1Id1}/services/{servicesId}:disable", + // "description": "Disable a service so that it can no longer be used with a project.\nThis prevents unintended usage that may cause unexpected billing\ncharges or security leaks.\n\nIt is not valid to call the disable method on a service that is not\ncurrently enabled. Callers will receive a `FAILED_PRECONDITION` status if\nthe target service is not currently enabled.\n\nOperation\u003cresponse: DisableServiceResponse\u003e", + // "flatPath": "v1/{v1Id}/{v1Id1}/services/{servicesId}:disable", // "httpMethod": "POST", // "id": "serviceusage.services.disable", // "parameterOrder": [ @@ -5214,7 +5429,7 @@ func (c *ServicesDisableCall) Do(opts ...googleapi.CallOption) (*Operation, erro // "type": "string" // } // }, - // "path": "v1beta1/{+name}:disable", + // "path": "v1/{+name}:disable", // "request": { // "$ref": "DisableServiceRequest" // }, @@ -5232,7 +5447,7 @@ func (c *ServicesDisableCall) Do(opts ...googleapi.CallOption) (*Operation, erro // method id "serviceusage.services.enable": type ServicesEnableCall struct { - s *APIService + s *Service name string enableservicerequest *EnableServiceRequest urlParams_ gensupport.URLParams @@ -5243,7 +5458,7 @@ type ServicesEnableCall struct { // Enable: Enable a service so that it can be used with a // project. // -// Operation +// Operation func (r *ServicesService) Enable(name string, enableservicerequest *EnableServiceRequest) *ServicesEnableCall { c := &ServicesEnableCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name @@ -5290,7 +5505,7 @@ func (c *ServicesEnableCall) doRequest(alt string) (*http.Response, error) { reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") - urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+name}:enable") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:enable") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("POST", urls, body) if err != nil { @@ -5341,8 +5556,8 @@ func (c *ServicesEnableCall) Do(opts ...googleapi.CallOption) (*Operation, error } return ret, nil // { - // "description": "Enable a service so that it can be used with a project.\n\nOperation\u003cresponse: google.protobuf.Empty\u003e", - // "flatPath": "v1beta1/{v1beta1Id}/{v1beta1Id1}/services/{servicesId}:enable", + // "description": "Enable a service so that it can be used with a project.\n\nOperation\u003cresponse: EnableServiceResponse\u003e", + // "flatPath": "v1/{v1Id}/{v1Id1}/services/{servicesId}:enable", // "httpMethod": "POST", // "id": "serviceusage.services.enable", // "parameterOrder": [ @@ -5357,7 +5572,7 @@ func (c *ServicesEnableCall) Do(opts ...googleapi.CallOption) (*Operation, error // "type": "string" // } // }, - // "path": "v1beta1/{+name}:enable", + // "path": "v1/{+name}:enable", // "request": { // "$ref": "EnableServiceRequest" // }, @@ -5375,7 +5590,7 @@ func (c *ServicesEnableCall) Do(opts ...googleapi.CallOption) (*Operation, error // method id "serviceusage.services.get": type ServicesGetCall struct { - s *APIService + s *Service name string urlParams_ gensupport.URLParams ifNoneMatch_ string @@ -5438,7 +5653,7 @@ func (c *ServicesGetCall) doRequest(alt string) (*http.Response, error) { var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") - urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+name}") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { @@ -5452,13 +5667,13 @@ func (c *ServicesGetCall) doRequest(alt string) (*http.Response, error) { } // Do executes the "serviceusage.services.get" call. -// Exactly one of *Service or error will be non-nil. Any non-2xx status -// code is an error. Response headers are in either -// *Service.ServerResponse.Header or (if a response was returned at all) -// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to -// check whether the returned error was because http.StatusNotModified -// was returned. -func (c *ServicesGetCall) Do(opts ...googleapi.CallOption) (*Service, error) { +// Exactly one of *GoogleApiServiceusageV1Service or error will be +// non-nil. Any non-2xx status code is an error. Response headers are in +// either *GoogleApiServiceusageV1Service.ServerResponse.Header or (if a +// response was returned at all) in error.(*googleapi.Error).Header. Use +// googleapi.IsNotModified to check whether the returned error was +// because http.StatusNotModified was returned. +func (c *ServicesGetCall) Do(opts ...googleapi.CallOption) (*GoogleApiServiceusageV1Service, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { @@ -5477,7 +5692,7 @@ func (c *ServicesGetCall) Do(opts ...googleapi.CallOption) (*Service, error) { if err := googleapi.CheckResponse(res); err != nil { return nil, err } - ret := &Service{ + ret := &GoogleApiServiceusageV1Service{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, @@ -5490,7 +5705,7 @@ func (c *ServicesGetCall) Do(opts ...googleapi.CallOption) (*Service, error) { return ret, nil // { // "description": "Returns the service configuration and enabled state for a given service.", - // "flatPath": "v1beta1/{v1beta1Id}/{v1beta1Id1}/services/{servicesId}", + // "flatPath": "v1/{v1Id}/{v1Id1}/services/{servicesId}", // "httpMethod": "GET", // "id": "serviceusage.services.get", // "parameterOrder": [ @@ -5505,9 +5720,9 @@ func (c *ServicesGetCall) Do(opts ...googleapi.CallOption) (*Service, error) { // "type": "string" // } // }, - // "path": "v1beta1/{+name}", + // "path": "v1/{+name}", // "response": { - // "$ref": "Service" + // "$ref": "GoogleApiServiceusageV1Service" // }, // "scopes": [ // "https://www.googleapis.com/auth/cloud-platform", @@ -5520,7 +5735,7 @@ func (c *ServicesGetCall) Do(opts ...googleapi.CallOption) (*Service, error) { // method id "serviceusage.services.list": type ServicesListCall struct { - s *APIService + s *Service parent string urlParams_ gensupport.URLParams ifNoneMatch_ string @@ -5618,7 +5833,7 @@ func (c *ServicesListCall) doRequest(alt string) (*http.Response, error) { var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") - urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+parent}/services") + urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/services") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { @@ -5670,7 +5885,7 @@ func (c *ServicesListCall) Do(opts ...googleapi.CallOption) (*ListServicesRespon return ret, nil // { // "description": "List all services available to the specified project, and the current\nstate of those services with respect to the project. The list includes\nall public services, all services for which the calling user has the\n`servicemanagement.services.bind` permission, and all services that have\nalready been enabled on the project. The list can be filtered to\nonly include services in a specific state, for example to only include\nservices enabled on the project.", - // "flatPath": "v1beta1/{v1beta1Id}/{v1beta1Id1}/services", + // "flatPath": "v1/{v1Id}/{v1Id1}/services", // "httpMethod": "GET", // "id": "serviceusage.services.list", // "parameterOrder": [ @@ -5701,7 +5916,7 @@ func (c *ServicesListCall) Do(opts ...googleapi.CallOption) (*ListServicesRespon // "type": "string" // } // }, - // "path": "v1beta1/{+parent}/services", + // "path": "v1/{+parent}/services", // "response": { // "$ref": "ListServicesResponse" // }, diff --git a/vendor/modules.txt b/vendor/modules.txt index e49af58c..58533a20 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -316,7 +316,7 @@ google.golang.org/api/pubsub/v1 google.golang.org/api/redis/v1beta1 google.golang.org/api/runtimeconfig/v1beta1 google.golang.org/api/servicemanagement/v1 -google.golang.org/api/serviceusage/v1beta1 +google.golang.org/api/serviceusage/v1 google.golang.org/api/sourcerepo/v1 google.golang.org/api/spanner/v1 google.golang.org/api/sqladmin/v1beta4 diff --git a/website/docs/r/google_project_service.html.markdown b/website/docs/r/google_project_service.html.markdown index b0d7441e..5a18f9bb 100644 --- a/website/docs/r/google_project_service.html.markdown +++ b/website/docs/r/google_project_service.html.markdown @@ -22,6 +22,8 @@ For a list of services available, visit the resource "google_project_service" "project" { project = "your-project-id" service = "iam.googleapis.com" + + disable_dependent_services = true } ``` @@ -33,6 +35,9 @@ The following arguments are supported: * `project` - (Optional) The project ID. If not provided, the provider project is used. +* `disable_dependent_services` - (Optional) If `true`, services that are enabled and which depend on this service should also be disabled when this service is destroyed. +If `false` or unset, an error will be generated if any enabled services depend on this service when destroying it. + * `disable_on_destroy` - (Optional) If true, disable the service when the terraform resource is destroyed. Defaults to true. May be useful in the event that a project is long-lived but the infrastructure running in that project changes frequently. ## Import